Advertisement
anhkiet2507

DEM TU - WA

Sep 1st, 2021
2,102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3. #include<cstring>
  4. using namespace std;
  5.  
  6.  
  7. int main() {
  8.     int t;
  9.     cin >> t;
  10.     while(t--){
  11.         char chuoi[1000];
  12.         fflush(stdin);
  13.         cin.getline(chuoi, 1000);
  14.         int dodai = strlen(chuoi),i,dem=0;
  15.         if(chuoi[0]!=' '&&chuoi[0]!='\t'){
  16.             dem=1;
  17.         }
  18.         for(i = 0; i<dodai-1; i++){
  19.             if(chuoi[i]==' '||chuoi[i]=='\t'||chuoi[i]=='\n'){
  20.                 if(chuoi[i+1]!=' '&&chuoi[i+1]!='\t'&&chuoi[i]!='\n'){
  21.                     dem++;
  22.                 }
  23.             }
  24.         }
  25.         cout << dem << endl;
  26.  
  27.     }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement