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

这是一个需要大神的时代,一直WA,给跪了

Posted by TOBENO1 at 2013-08-04 22:29:34 on Problem 1318
#include<iostream>
#include<string>
using namespace std;

int main(){
	char w[105][7],q[105][7],r[105][7],a[7],temp2[7];
	int i,j,k,l,len,f,temp;
	bool temp1;
	for(i=0;;i++)
	{
		cin>>w[i];
		if(strcmp(w[i],"XXXXXX")==0)
			break;
	}
	while(cin>>a)
	{
		for(j=0;j<i;j++)
			strcpy(r[j],w[j]);
		f=0;
		temp1=false;
		if(strcmp(a,"XXXXXX")==0)
			break;
		len=strlen(a);
		for(j=0;j<i;j++)
		{
			temp=0;
			for(k=0;k<len;k++)
			{
				for(l=0;l<len;l++)
				{
					if(a[k]==r[j][l])
					{
						temp++;
						r[j][l]='?';
						break;
					}

				}
			}
			if(temp==len)
			{
				strcpy(q[f],w[j]);
				f++;
				temp1=true;
			}
		}
		if(temp1==false)
			cout<<"NOT A VALID WORD"<<endl;
		else
		{
			for(j=f-1;j>=0;j--)
			{
				for(k=0;k<j;k++)
					if(strcmp(q[k],q[k+1])>0)
					{
						strcpy(temp2,q[k]);
						strcpy(q[k],q[k+1]);
						strcpy(q[k+1],temp2);

					}
			}
			for(j=0;j<f;j++)
				cout<<q[j]<<endl;
		}
		cout<<"******"<<endl;

	}
	return 0;
}

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