Advertisement
volkovich_maksim

strings_with_>2016_number

Sep 25th, 2016
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.72 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.    
  4. int main(void){
  5.     enum {n = 2016};
  6.     int i, number = 0, maxline = 1000, flag = 0;
  7.     char buf[1000], c[1000];
  8.  
  9.     while (fgets(c, maxline, stdin)){
  10.         strcpy(buf, c);
  11.         number = 0;
  12.         i = 0;
  13.         while (i < maxline && buf[i] != EOF && buf[i] != '\0'){
  14.             if (buf[i] <= '9' && buf[i] >= '0'){
  15.                 number = number*10 + (buf[i] - '0');
  16.                 if (number > n){
  17.                     flag = 1;
  18.                 }
  19.             }
  20.             else{
  21.                 number = 0;
  22.             }
  23.             i++;
  24.     }
  25.  
  26.         if (flag == 1){
  27.             puts(c);
  28.         }        
  29.         flag = 0;
  30.     }
  31.    
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement