Advertisement
Guest User

Untitled

a guest
Aug 26th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include<string.h>
  4. #include<algorithm>
  5. #include<vector>
  6. #include<functional>
  7. using namespace std;
  8.  
  9. char C[1000010];
  10. int num = 0, n;
  11.  
  12. int main(void) {
  13. cin.getline(C,1000010);
  14. n = strlen(C);
  15. for (int i = 0; i < n; i++) {
  16. if (C[i] == ' '&& i == 0) {
  17.  
  18. }
  19. else if (C[i] == ' '&& i == n - 1) {
  20.  
  21. }
  22. else if (C[i] == ' ') {
  23. num++;
  24. }
  25. }
  26. if(n!=1 && n!=0 ) num++;
  27. cout << num;
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement