题目地址:
C++代码:
#include#include #include #include #include using namespace std;int main(){ string s; vector svec; while(getline(cin,s)) { int i; for(i=0;i<(int)s.size();++i) { if(isupper(s[i])) s[i]=s[i]-'A'+'a'; } string::iterator begin=s.begin(); for(;begin!=s.end()&&!isalpha(*begin);++begin); string::iterator end; if(begin==s.end()) end=begin; else end=begin+1; while(true) { if(begin==s.end()) break; for(;end!=s.end()&&isalpha(*end);++end); string str(begin,end); vector ::iterator iter=find(svec.begin(),svec.end(),str); if(iter==svec.end()) svec.push_back(str); for(;end!=s.end()&&!isalpha(*end);++end); begin=end; if(end!=s.end()) ++end; } } sort(svec.begin(),svec.end()); vector ::iterator iter=svec.begin(); while(iter!=svec.end()) cout<<*iter++<