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 |
有空的大神帮俺看看,这么写为啥就不行啊#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int main(){ string s; vector<string> vs; bool flag; while(cin>>s,s[1]!='X'){ vs.push_back(s); } sort(vs.begin(),vs.end());//字典顺序排序 while(cin>>s,s[1]!='X'){ flag = true; for(int i = 0;i<vs.size();i++){ //在vs[i]中找不属于s的字符,并在s中找不属于vs[i]的字符,都找不到说明“相等” if(((vs[i].find_first_not_of(s))==string::npos)&&((s.find_first_not_of(vs[i]))==string::npos)){ cout<<vs[i]<<endl; if(flag) flag=false;//控制“NOT A VALID WORD”的输出 } } if(flag) cout<<"NOT A VALID WORD"<<endl; cout<<"******"<<endl; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator