[Algorithm] BOJ 1152
#include <iostream>
#include <string>
using namespace std;
int main()
{
string tmp;
int num = 0;
getline(cin,tmp);
for(int i = 0; i<tmp.size(); i++)
{
if(tmp[i] == 32)
num++;
}
if(tmp[0] == 32 && tmp[tmp.size()-1] == 32)
cout << num-1 << endl;
else if((tmp[0] == 32 || tmp[tmp.size()-1] == 32))
cout << --num + 1 << endl;
else
cout << num+1 << endl;
return 0;
}
댓글남기기