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 yellowflying at 2006-07-21 22:28:51 on Problem 1013
#include <stdio.h>
#include <string.h>
#include <math.h>

int main()
{
	int n,i,j,k,mark,max=0,t;
	char a[8],b[8],c[8],re;
	int flag[12];
	memset(flag,0,sizeof(flag));
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		mark=0;
		for(j=0;j<3;j++)
		{
			scanf("%s%s%s",a,b,c);
			if(c[0]=='e')
				for(k=0;a[k]!='\0';k++)
				{
					flag[a[k]-'A']=5;
					flag[b[k]-'A']=5;
				}
			else if(c[0]=='u')
				for(k=0;a[k]!='\0';k++)
				{
					if(flag[a[k]-'A']!=5)
						flag[a[k]-'A']+=1;
					if(flag[b[k]-'A']!=5)
						flag[b[k]-'A']+=-1;
				}
			else
				for(k=0;a[k]!='\0';k++)
				{
					if(flag[a[k]-'A']!=5)
						flag[a[k]-'A']+=-1;
					if(flag[a[k]-'A']!=5)
						flag[b[k]-'A']+=1;
				}
		}
		for(i=0;i<12;i++)
		{
			mark=abs(flag[i]);
			if(mark>max&&mark!=5)
			{
				t=i;
				max=mark;
			}
		}
		re=t+'A';
		printf("%c is the counterfeit coin ",re);
		if(flag[t]<0)
			printf("and it is light.\n");
		else
			printf("and it is heavy.\n");
		
	}
	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