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 zhangkeabcd at 2010-08-06 16:57:57 on Problem 2159
#include<iostream>
#include<string.h>
using namespace std;
char a[200],b[200],x[200],y[200];
int main()
{
	int i,j,m,k;
	gets(a);
	gets(b);
	m=strlen(a);
	for(i=0;i<m;i++)
	{
		char r='z';
		for(j=0;j<m;j++)
		{
			if(r>=a[j])
			{
				r=a[j];
				k=j;
			}
		}
		x[i]=a[k];
		a[k]='z';
	}
	for(i=0;i<m;i++)
	{
		char r='z';
		for(j=0;j<m;j++)
		{
			if(r>=b[j])
			{
				r=b[j];
				k=j;
			}
		}
		y[i]=b[k];
		b[k]='z';
	}
	puts(x);
	puts(y);
	int tmp=1;
	int s=x[0]-y[0];
	for(i=1;i<m;i++)
	{
		if(x[i]-y[i]!=s)
		{
			tmp=0;
			break;
		}
	}
	if(tmp==1)
		cout<<"YES";
	else
		cout<<"NO";
	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