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 dayangou at 2008-07-13 22:30:52 on Problem 1013
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int main()
{
	int a[12],n,temp,i,j,tem;
	for(i=0;i<12;i++)
		a[i]=50;
	char t1[6],t2[6],s[5];
	scanf("%d",&n);
	while(n)
	{
		for(i=0;i<3;i++)
		{
			scanf("%s %s %s",t1,t2,s);
			switch(s[0])
			{
			case 'u':
				for(j=0;j<6;j++)
				{
					if(t1[j]<'A'||t1[j]>'z')
						break;
					temp=int(t1[j])-65;
			        if(a[temp]!=0)
						a[temp]+=1;
				}
				for(j=0;j<6;j++)
				{
					if(t2[j]<'A'||t2[j]>'z')
						break;
					temp=int(t2[j])-65;
			        if(a[temp]!=0)
						a[temp]-=1;
				}
				break;
			case 'd':
				for(j=0;j<6;j++)
				{
					if(t1[j]<'A'||t1[j]>'z')
						break;
					temp=int(t1[j])-65;
			        if(a[temp]!=0)
						a[temp]-=1;
				}
				for(j=0;j<6;j++)
				{
					if(t2[j]<'A'||t2[j]>'z')
						break;
					temp=int(t2[j])-65;
			        if(a[temp]!=0)
						a[temp]+=1;
				}
				break;
			case 'e':
				for(j=0;j<6;j++)
				{
					if(t1[j]<'A'||t1[j]>'z')
						break;
					temp=int(t1[j])-65;
					a[temp]=0;
				}
				for(j=0;j<6;j++)
				{
					if(t2[j]<'A'||t2[j]>'z')
						break;
					temp=int(t2[j])-65;
					a[temp]=0;
				}
				break;
			}
			for(j=0;j<6;j++)
			{
				t1[j]=0;
				t2[j]=0;
			}
		}
		temp=0;
		for(i=0;i<12;i++)
		{
			if(abs(a[i]-50)>temp&&a[i]!=50&&a[i]!=0)
			{
				temp=abs(a[i]-50);
				tem=i;
			}
		}
		if(a[tem]-50>0)
			printf("%c is the counterfeit coin and it is heavy.\n",char(tem+65));
//			cout<<char(tem+65)<<" is the counterfeit coin and it is heavy."<<endl;
		if(a[tem]-50<0)
			printf("%c is the counterfeit coin and it is light.\n",char(tem+65));
//			cout<<char(tem+65)<<" is the counterfeit coin and it is light."<<endl;
		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