输入一个文本,找出所有不同的单词(连续的字母序列),按字典序从小到大输出,单词不区分大小写。



Adventures in Disneyland
Two blondes were going to Disneyland when they came to a fork in the
road. The sign read: "Disneyland Left."
So they went home.
a
adventures
blondes
came
disneyland
fork
going
home
in
left
read
road
sign
so
the
they
to
two
went
were
when
我的代码是:
#include <cstdio>
#include <iostream>
#include <set>
#include <string>
#include <sstream>
using namespace std;
int main()
{
ios::sync_with_stdio(false), cin.tie(0);
set<string> a;
string i;
while (cin >> i)
{
string k = "";
for (char b : i)
{
if ((b >= 'A' && b <= 'Z') || (b >= 'a' && b <= 'z'))
{
if (b >= 'A' && b <= 'Z')
{
b = b - 'A' + 'a';
}
k += b;
}
}
stringstream ss(k);
a.insert(k);
}
for (const string &k : a)
{
cout << k << endl;
}
return 0;
}