Advertisement
Joao_Joao

Getline One - C

May 14th, 2022
832
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement