Advertisement
Arch_of_Triumph

Untitled

Dec 11th, 2023
608
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.23 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     string s;
  7.     getline(cin, s);
  8.  
  9.     int countWords = 1;
  10.     for (int i = 0; i < s.size(); i++) {
  11.         if (s[i] == ' ') {
  12.             countWords++;
  13.         }
  14.     }
  15.  
  16.     cout << countWords;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement