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

Re:刚学C++,努力用C++做这题,可是一直WA,各位大侠进来看一下

Posted by hebeboy at 2009-05-12 19:09:21 on Problem 1318
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:
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