Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

有空的大神帮俺看看,这么写为啥就不行啊

Posted by iFinVer at 2012-08-04 16:29:19 on Problem 1318
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator