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

Re:是不是有些数据无法确定答案的?高手帮忙看看吧

Posted by kicc at 2004-04-08 13:17:02 on Problem 1013
In Reply To:是不是有些数据无法确定答案的?高手帮忙看看吧 Posted by:Loger at 2004-04-08 09:13:53
没有,应该是你的程序有问题
> #include <stdio.h>
> void main()
> {
>   int n;
>   int flag[20][3];
>   char num[2][20];
>   char tmp[10];
>   int i,j;
>   scanf("%d",&n);
>   while(n--)
>     {
>     for(i=0;i<20;i++)
>        for(j=0;j<3;j++) flag[i][j]=0;
>     for(i=1;i<=3;i++)
>       {
>       scanf("%s %s %s",num[0],num[1],tmp);
>       if(tmp[0]=='e') 
>           {
>           for(j=0;num[0][j]!='\0';j++) flag[num[0][j]-'A'][0]=1;
>           for(j=0;num[1][j]!='\0';j++) flag[num[1][j]-'A'][0]=1;   
>           }
>       else if(tmp[0]=='u') 
>           {
>           for(j=0;num[0][j]!='\0';j++) flag[num[0][j]-'A'][2]=1;
>           for(j=0;num[1][j]!='\0';j++) flag[num[1][j]-'A'][1]=1;   
>           }
>       else if(tmp[0]=='d')  
>           {
>           for(j=0;num[0][j]!='\0';j++) flag[num[0][j]-'A'][1]=1;
>           for(j=0;num[1][j]!='\0';j++) flag[num[1][j]-'A'][2]=1;   
>           }          
>        }
>    for(i=0;i<12;i++)
>      if(flag[i][0]!=1&&flag[i][1]+flag[i][2]==1)
>           break;
>    if(flag[i][2]==1) printf("%c is the counterfeit coin and it is heavy.\n",(char)i+'A');   
>    else if(flag[i][1]==1) printf("%c is the counterfeit coin and it is light.\n",(char)i+'A');       
>    }
> }
> 
> 
> 
> 
> 
> 
> 
> 

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