Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:刚学C++,努力用C++做这题,可是一直WA,各位大侠进来看一下In Reply To:刚学C++,努力用C++做这题,可是一直WA,各位大侠进来看一下 Posted by:sunpy_another at 2009-02-22 15:42:47 #include<iostream> #include<map> #include<string> #include<set> #include<vector> #include<algorithm> using namespace std; typedef set<string>::iterator Set_type; bool Compare( string s1,string& s2) { if(s1.size()!=s2.size()) return 0; sort(s1.begin(),s1.end()); sort(s2.begin(),s2.end()); if(s1 ==s2) return 1; return 0; } int main() { vector<string> words; set<string> set1; string s; while(cin>>s){ if(s=="XXXXXX") break; words.push_back(s); } while(cin>>s) { set1.clear(); if(s=="XXXXXX") break; for(vector<string>::iterator it = words.begin();it!=words.end();++it) if(Compare(*it,s)) set1.insert(*it); Set_type beg = set1.begin(); Set_type end = set1.end(); if(beg == end) cout<<"NOT A VALID WORD"<<endl; while(beg!=end){ cout<<*beg<<endl; ++beg; } cout<<"******"<<endl; } return 0; } set没清零 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator