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

1013 compile error!? 我在自己的机子测N组数据都能过……

Posted by casual0402 at 2008-05-20 20:06:39
#include <stdio.h>
#include <string.h>

void dele(int n,char c[])
{   
	int i,clen;
	clen=strlen(c);
    for(i=n;i<clen;i++)
	{
		c[i]=c[i+1];
	}
}

void del(char a[],char b[])
{   
	int i,j,alen,blen;
	alen=strlen(a);
	blen=strlen(b);
    for (i=0;i<alen;i++)
	{
		for(j=0;j<blen;j++)
		{
			if(a[i]==b[j]) dele(j,b);
		}
	}
}

int main()
{
	int i,j,k,m,n,times,llen,rlen,alen;
	i=j=1;
	char left[10],right[10],status[10],allbackup[20];
	char all[20]={"ABCDEFGHIJKL"};
	int flag[20]={0};
	scanf("%d",&times);
	for(i=1;i<=times;i++)
	{
		for(j=1;j<=3;j++)
		{
			scanf("%s %s %s",left,right,status);
			llen=strlen(left);
			rlen=strlen(right);
			if (status[0]=='e')
			{
				for(m=0;m<llen;m++)
				{
					for(n=0;n<12;n++)
					{
						if((left[m]==all[n])||(right[m]==all[n])) flag[n]=2;
					}
				}
			}

			/* 可以用以下代码测试even状态时的代码对错
			for(k=0;k<12;k++)
			{
				if(flag[k]==2) printf("确定为真银币:%c\n",all[k]);
			}
			*/

			if(status[0]=='u')
			{
				strcpy(allbackup,all);
				del(left,all);del(right,all);
				alen=strlen(all);
				for(n=0;n<12;n++)
				{
					for(m=0;m<alen;m++)
					{
						if(allbackup[n]==all[m]) flag[n]=2;
					}
				}
				strcpy(all,allbackup);

				/* codes below will test the exactness from "strcpy" here
			    for(k=0;k<12;k++)
			    {
				    if(flag[k]==2) printf("确定为真银币:%c\n",all[k]);
			    }	
				*/
			
				for(n=0;n<12;n++)
				{
					for(m=0;m<llen;m++)
					{
						if(left[m]==all[n])
						{
							if(flag[n]==0) flag[n]=1;
							if(flag[n]==-1) flag[n]=2;
						}
						if(right[m]==all[n])
						{
							if(flag[n]==0) flag[n]=-1;
							if(flag[n]==1) flag[n]=2;
						}
					}
				}

				/* codes below are to test the exactness of the codes above
				for(k=0;k<12;k++)
				{
				    if (flag[k]==-1) printf("%c may be light\n",all[k]);
					if (flag[k]==1) printf("%c may be heavy\n",all[k]);
					if (flag[k]==2) printf("%c is real\n",all[k]);
				}
				*/

			}
			if(status[0]=='d')
			{
				strcpy(allbackup,all);
				del(left,all);del(right,all);
				alen=strlen(all);
				for(n=0;n<12;n++)
				{
					for(m=0;m<alen;m++)
					{
						if(allbackup[n]==all[m]) flag[n]=2;
					}
				}
				strcpy(all,allbackup);

				/* codes below will test the exactness from "strcpy" here
			    for(k=0;k<12;k++)
			    {
				    if(flag[k]==2) printf("确定为真银币:%c\n",all[k]);
			    }	
				*/

				for(n=0;n<12;n++)
				{
					for(m=0;m<llen;m++)
					{
						if(left[m]==all[n])
						{
							if(flag[n]==0) flag[n]=-1;
							if(flag[n]==1) flag[n]=2;
						}
						if(right[m]==all[n])
						{
							if(flag[n]==0) flag[n]=1;
							if(flag[n]==-1) flag[n]=2;
						}
					}
				}
                /* codes below are to test the exactness above
				for(k=0;k<12;k++)
				{
				    if (flag[k]==-1) printf("%c may be light\n",all[k]);
					if (flag[k]==1) printf("%c may be heavy\n",all[k]);
					if (flag[k]==2) printf("%c is real\n",all[k]);
				}
				*/

			}
			
		}
	    for(k=0;k<12;k++)
		{
	     	if(flag[k]==1) printf("%c is the counterfeit coin and it is heavy.\n",allbackup[k]);
	    	if(flag[k]==-1) printf("%c is the counterfeit coin and it is light.\n",allbackup[k]);
		}
		for(k=0;k<20;k++)
		{
			flag[k]=0;
		}

	}

	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