The_Law

Untitled

Dec 28th, 2017
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. void cnt(void)
  6. {
  7.    FILE* in = fopen("input.txt", "r");
  8.    int res = 0;
  9.    int tmp = 0;
  10.  
  11.     while (!feof(in))
  12.     {
  13.         char c;
  14.  
  15.         fscanf(in, "%c", &c);
  16.  
  17.         if (!feof(in))
  18.             if (c == ' ')
  19.             {
  20.                 if (tmp == 101)
  21.                   ++res;
  22.                 tmp = 0;
  23.             }
  24.             else if ('0' <= c && c <= '9')
  25.                 tmp = tmp *10 + c - '0';
  26.             ///else figach oshibku
  27.     }
  28.  
  29.     if (tmp == 101)
  30.         ++res;
  31.  
  32.     printf("%d", res);
  33. }
  34.  
  35. int main(void)
  36. {
  37.     cnt();
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment