#include <iostream>
#include <string>
using namespace std;
int main(void) {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
string str;
getline(cin, str);
if (str == " " || str == "") {
cout << 0 << endl;
return 0;
}
int wordCnt = 0;
for (int i = 0; i < str.size(); i++) {
if (str[i] == ' ') {
if (i == 0 || i == str.size() - 1) {
continue;
}
wordCnt++;
}
}
cout << wordCnt + 1 << endl;
return 0;
}
'문제풀이 > 백준' 카테고리의 다른 글
2941 - 크로아티아 알파벳 (0) | 2021.08.24 |
---|---|
5622 - 다이얼 (0) | 2021.08.24 |
1157 - 단어 공부 (0) | 2021.08.24 |
11720 - 숫자의 합 (0) | 2021.08.24 |
11654 - 아스키 코드 (0) | 2021.06.22 |