Сделал 1 Задание со списками
This commit is contained in:
parent
5dbf4901b8
commit
632a718df1
71 changed files with 106 additions and 0 deletions
24
ProcessingSequences/Sixth/exp_weigh_avg.c
Normal file
24
ProcessingSequences/Sixth/exp_weigh_avg.c
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#include "exp_weigh_avg.h"
|
||||
|
||||
int betweenZeroOne(double lambda) {
|
||||
if ((lambda < FAULT) || ((1 - lambda) <= FAULT)) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
double expWeigthAvg(FILE * file, double lambda) {
|
||||
double current, i, eavg, lambda_n;
|
||||
if (fscanf(file, "%lf", ¤t) != 1) {
|
||||
printf("File is empty!\n");
|
||||
return -1.;
|
||||
}
|
||||
|
||||
i = 1.;
|
||||
eavg = 0.;
|
||||
|
||||
do {
|
||||
eavg += current * pow(lambda, -i);
|
||||
i++;
|
||||
} while (fscanf(file, "%lf", ¤t) == 1);
|
||||
lambda_n = pow(lambda, i - 1);
|
||||
return (eavg * lambda_n) * ((1 - lambda) / (1 - lambda_n));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue