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

本人比较笨,贡献了n个WA,那位牛人帮忙看下啦(C做的)

Posted by anotherway at 2010-02-24 11:31:00 on Problem 2159 and last updated at 2010-02-24 11:32:20
#include <stdio.h>
#include <string.h>
void main()
{
	int i,j,n,x,y,m,cl,dl,c[200],d[200];
	char a[200],b[200];
	gets(a);
	gets(b);
	for (i=0;i<200;i++)  c[i]=d[i]=1;
	m=n=strlen(a); 
	
	cl=dl=0;
	for (i=0;i<m;i++)
	{
		cl++;
		for (j=i+1;j<m;j++)
			if (a[i]==a[j]) 
			{
				for (x=j;x<m;x++) a[x]=a[x+1];
				m--;
				c[cl]++;
			}
	}
	
				for (i=0;i<n;i++)
				{
					dl++;
					for (j=i+1;j<n;j++)
						if (b[i]==b[j]) 
						{
							for (x=j;x<n;x++) b[x]=b[x+1];
							n--;
							d[dl]++;
						}
				}

				if (cl!=dl) printf("NO\n");
				else
				{
					x=0;
					for (i=1;i<cl;i++)
						for (j=1;j<dl;j++)
							if (c[i]=d[j]) 
							{
								for (y=j;y<dl;y++) d[y]=d[y+1];
								x=1;dl--;break;
							}
							if (x==0) printf("NO\n");
							else printf("YES\n");
				}
}

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