Сделал 1 Задание со списками
This commit is contained in:
parent
5dbf4901b8
commit
632a718df1
71 changed files with 106 additions and 0 deletions
30
ProcessingSequences/10Ex/count_between.c
Normal file
30
ProcessingSequences/10Ex/count_between.c
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#include "count_between.h"
|
||||
|
||||
double fmax(double a, double b) {
|
||||
if ((a - b) > eps) return a;
|
||||
return b;
|
||||
}
|
||||
|
||||
double fmin(double a, double b) {
|
||||
if ((a - b) > eps) return b;
|
||||
return a;
|
||||
}
|
||||
|
||||
int countBetween(FILE * file) {
|
||||
double first, second, current;
|
||||
int count = 0;
|
||||
|
||||
if ((fscanf(file, "%lf", &first) != 1) || (fscanf(file, "%lf", &second) != 1)) {
|
||||
printf("There is NO 2 variables\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
current = fmax(first, second);
|
||||
second = fmin(first, second);
|
||||
first = current;
|
||||
|
||||
while (fscanf(file, "%lf", ¤t) == 1) {
|
||||
if (((current - second) > eps) && ((first - current) > eps)) count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue