fork(1) download
  1. #include <stdio.h>
  2.  
  3. int main(void)
  4. {
  5. char str[1000001];
  6. int count = 0, result = 0;
  7. scanf("%[^\n]s", str);
  8. for (int i = 0; str[i] != '\0'; i++)
  9. {
  10. count++;
  11. }
  12. int arr[count];
  13. for (int i = 0; str[i] != '\0'; i++)
  14. {
  15.  
  16. if (str[i] != 32)
  17. {
  18. arr[i] = 1;
  19. }
  20. else
  21. {
  22. arr[i] = 0;
  23. }
  24. }
  25.  
  26. if (str[0] == 32 && str[1]!='\0')
  27. {
  28. for (int i = 0; i < count; i++)
  29. if (arr[i] == 0)
  30. result++;
  31. printf("%d\n", result);
  32. }
  33. else if (str[0] != 32)
  34. {
  35. result = 1;
  36. for (int i = 0; i < count; i++)
  37. if (arr[i] == 0)
  38. result++;
  39. printf("%d\n", result);
  40. }
  41. else if (str[0] == 32 && str[1] == '\0')
  42. printf("%d\n", 0);
  43.  
  44. return 0;
  45. }
  46.  
Success #stdin #stdout 0s 5596KB
stdin
 a 
stdout
2