Сделал 1 Задание со списками
This commit is contained in:
parent
5dbf4901b8
commit
632a718df1
71 changed files with 106 additions and 0 deletions
23
ProcessingSequences/Fourth/max_difference.c
Normal file
23
ProcessingSequences/Fourth/max_difference.c
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#include "max_difference.h"
|
||||
|
||||
int max(int first, int second) {
|
||||
if (first > second) return first;
|
||||
return second;
|
||||
}
|
||||
|
||||
int maxDifference(FILE * file) {
|
||||
int current, last, maxim;
|
||||
if (fscanf(file, "%d", ¤t) != 1) {
|
||||
printf("File is empty!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
last = current;
|
||||
maxim = 0;
|
||||
|
||||
while (fscanf(file, "%d", ¤t) == 1) {
|
||||
maxim = max(maxim, abs(last - current));
|
||||
last = current;
|
||||
}
|
||||
return maxim;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue