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 emperorlu at 2007-12-16 19:03:01 on Problem 1013
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
    int n;
    scanf("%d",&n);
    while(n--)
    {
        char left[5],right[5],mid[5];
        int check[13];
        memset(check,0,sizeof(check));
        for(int i=1;i<=3;i++)
        {
            scanf("%s%s%s",left,right,mid);
            if(strcmp(mid,"up")==0)
            {
                for(int j=0;left[j];j++)
                {
                    int lf,rt;
                    lf=left[j]-'A';
                    rt=right[j]-'A';
                    if(check[lf]==0)
                    {
                        check[lf]=1;
                    }
                    else if(check[lf]==-1)
                    {
                        check[lf]=2;
                    }
                    if(check[rt]==0)
                    {
                        check[rt]=-1;
                    }
                    else if(check[rt]==1)
                    {
                        check[rt]=2;
                    }
                }
            }
            else if(strcmp(mid,"down")==0)
            {
                for(int j=0;left[j];j++)
                {
                    int lf,rt;
                    lf=left[j]-'A';
                    rt=right[j]-'A';
                    if(check[lf]==0)
                    {
                        check[lf]=-1;
                    }
                    else if(check[lf]==1)
                    {
                        check[lf]=2;
                    }
                    if(check[rt]==0)
                    {
                        check[rt]=1;
                    }
                    else if(check[rt]==-1)
                    {
                        check[rt]=2;
                    }
                }
            }
            else
            {
                for(int j=0;left[j];j++)
                {
                    check[left[j]-'A']=2;
                    check[right[j]-'A']=2;
                }
            }
        }

        for(int i=0;i<12;i++)
        {
            if(check[i]==-1)
            {
                printf("%c is the counterfeit coin and it is light.\n",i+'A');
            }
            else if(check[i]==1)
            {
                printf("%c is the counterfeit coin and it is heavy.\n",i+'A');
            }
        }
    }
    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