fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main() {
  6. ios::sync_with_stdio(false); cin.tie(NULL);
  7. string str;
  8. int count = 0;
  9. getline(cin, str);
  10.  
  11. for (int i = 0; i < str.length() - 1; i++) {
  12. if(i == 0)
  13. count++;
  14.  
  15. else if (str[i] == ' ') {
  16. count++;
  17. }
  18. }
  19. cout << count << "\n";
  20. return 0;
  21. }
Success #stdin #stdout 0s 4972KB
stdin
a
stdout
0