0084 - Search Engine

#include <iostream>
#include <sstream>
#include <string>
using namespace std;

void Slove(string str)	{
	string word;
	stringstream ss;
	bool flg=false;

	for (int i=0; i<str.length(); ++i)
		if (str[i]=='.' || str[i]==',')	str[i]=' ';
	ss << str;
	while (ss >> word)
		if (3<=word.length() && word.length()<=6)	{
			(flg)? cout << " " : flg=true;
			cout << word;
		}
	cout << endl;
}

int main(void)	{
	string str;

	getline(cin,str);
	Slove(str);
	return 0;
}

うん、stringstreamを使いたかった。。