fork(1) download
  1. #include <string.h>
  2. #include <stdio.h>
  3. int main(void)
  4. {
  5. int t, i, len, ans;
  6. char a[1000];
  7. scanf ("%d", &t);
  8. for (t; t > 0; --t)
  9. {
  10. gets(a);
  11. len = strlen(a);
  12. ans = 0;
  13. for (i = 0; i < len; ++i)
  14. {
  15. if (a[i] == 32)
  16. ans = ans + 1;
  17. }
  18. printf ("%d\n", ans + 1);
  19. }
  20. return 0;
  21. }
Success #stdin #stdout 0s 2252KB
stdin
4
I can do this!
Yes, I will win
Code Haxor!
Taqneeq FTW!
stdout
1
4
4
2