Advertisement
Guest User

Прога на Си на среднее арифмитесечкое постоянных.

a guest
Sep 14th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.40 KB | None | 0 0
  1. float dataProcessing(FILE *fin) {
  2.     long x,y,summ;
  3.     int counter = 1;
  4.     float result;
  5.     if (fscanf(fin,"%lf",&y)!=1) return -1;
  6.    
  7.     while(fscanf(fin,"%lf",&x) = 1) {
  8.         if (x!=y) {
  9.             summ += y;
  10.             y = x;
  11.             counter++;
  12.             continue;
  13.         } else {
  14.             y = x;
  15.         }
  16.     }
  17.     result = summ / counter;
  18.     return result;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement