#include <iostream>
#include <string>
#include <vector>
#include <charconv>
using namespace std;
int main(void)
{
ios::sync_with_stdio(false);
cin.tie(NULL);
string al;
getline(cin, al);
int count = 1;
if (al.size() == 1)
{
if (al[0] == ' ')
{
cout << 0 << '\n';
return 0;
}
}
for (int i = 0; i < al.size() - 1; ++i)
{
if (i == 0 && al[0] == ' ')
{
continue;
}
if ((al[i] == ' ') && (al[i + 1] != '\0'))
{
count++;
}
}
cout << count << '\n';
return 0;
}
코딩 테스트