UVa10815 - Andy's First Dictionary
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <cctype> using namespace std; int main() { string s; vector<string> 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<string>::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<string>::iterator iter=svec.begin(); while(iter!=svec.end()) cout<<*iter++<<endl; return 0; }
补充:软件开发 , C++ ,