Advertisement
Joao_Joao

Getline One - C

May 14th, 2022
979
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.31 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.   size_t size = 100;
  5.   char p[size], *pp = p;
  6.   int num = 0, x, ant = -1;
  7.   double sum = 0;
  8.   while(getline(&pp, &size, stdin) != EOF) {
  9.     scanf("%d", &x);
  10.     if(x == ant) continue;
  11.     ant = x, sum += x, ++num;
  12.   }
  13.   printf("%.1lf\n", sum / num);
  14.  
  15.   return 0;
  16. }
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement