Description
XY学长刚刚立下了再不过CET就直播xx的flag,为了不真的开启直播模式,XY学长决定好好学习英语。于是他每天都读一篇只包含生词的英语文章,并以自己高达450的智商在一秒钟之内记忆下来。
现在给你一篇XY学长今天要读的文章,请你写一个程序,输出他都学习到了哪些单词。
要求:如果文章中有相同的单词,那么仅仅输出一次;而且如果两个单词只有大小写不同,将他们视为相同的单词。
Input
测试数据将输入一篇文章。不超过5000行,每一行最多200个字符,并以EOF结束。
Output
按照字典序输出他学到的单词,每行输出一个单词,输出单词时所有的字母全部小写。
数据保证最多有5000个需要输出的单词。
Sample Input
样例输入①
a a a a a a a a, a a a a a a. a a a a b a a a. a? a!!!
样例输入②
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.
Sample Output
样例输出①
a b
样例输出②
a adventures blondes came disneyland fork going home in left read road sign so the they to two went were when
很好去除了多余的符号
stringstream ss(str1);
while(ss>>str2)
{
s.insert(str2);//作用是去掉左边右边多余的符号
//cout<<str2<<endl;
}
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=10000+66;
const ll mod=1000000009;
int n,m;
int a[maxn];
set<string>s;
string str1,str2;
int main()
{
while(cin>>str1)
{
int len=str1.size();
for(int i=0; i<len; i++)
{
if(isalpha(str1[i]))
{
str1[i]=tolower(str1[i]);
}
else
{
str1[i]=' ';
}
}
stringstream ss(str1);
while(ss>>str2)
{
s.insert(str2);//作用是去掉左边右边多余的符号
//cout<<str2<<endl;
}
}
set<string>::iterator it;
for(it=s.begin(); it!=s.end(); it++)
{
cout<<*it<<endl;
}
return 0;
}