fork(1) download
  1. #include<stdio.h>
  2. #include<string.h>
  3. int main(){
  4. int T;
  5. scanf("%d",&T);
  6. while(T--)
  7. {
  8. char s[1005];
  9. fgets(s,sizeof(s),stdin);
  10. int count=0;
  11. for(int i=0;i<strlen(s);i++)
  12. {
  13. if(s[i]==' '&&s[i+1]!=' ')
  14. count++;
  15. }
  16. printf("%d\n",count);
  17. }
  18. }
  19.  
Success #stdin #stdout 0s 5376KB
stdin
Standard input is empty
stdout
0