Advertisement
silentkiler029

how many numbers are there?

Jul 1st, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.59 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main()
  5. {
  6.     int T;
  7.     scanf("%d", &T);
  8.     getchar();
  9.  
  10.     char str[1000000];
  11.     int i, len, count, flag; //flag = 1 >> paichi
  12.  
  13.     while(T--){
  14.         gets(str);
  15.         len = strlen(str);
  16.         count = 0;
  17.        
  18.         for(i = 0; i < len; i++){
  19.             if(str[i] != ' '){
  20.                 flag = 1;
  21.             }
  22.             else{
  23.                 if(flag == 1){
  24.                     count++;
  25.                 }
  26.                 flag = 0;
  27.             }
  28.         }
  29.         printf("%d\n", count + 1);
  30.     }
  31.  
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement