Description
DongDong prefers English words to English sentences, so he wants to count the words of a sentence. Could you help him?
Input
The first line contains a positive integer T (T<=1000), which means T test cases. Then comes T lines, each line contains a string which combines with several words separated by spaces. Note that there may be more than one space to separate two words.
Output
For each test case, please print the number of words of the sentence.
Sample Input
3 Every night in my dreams I see you I feel you That is how I know you go on
Sample Output
5 6 8
#include<string.h>
int main() {
int T;
scanf("%d",&T);
getchar();
while(T--){
char a[1000];
gets(a);
int i;
int num=0;
for(i=1;i<strlen(a);i++){
if(a[i-1]==' '&&a[i]!=' '){
num=num+1;
}
}
if(a[0]!=' ')num++;
printf("%d\n",num);
}
}