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

大牛们帮看看哪错了。。。。

Posted by zxykid at 2011-07-06 11:04:03 on Problem 1013
#include"stdio.h"
#include"string.h"
#include"math.h" 

int main( void )
{
    int i, j;
    int z;
    char left[10][50], right[10][50], com[10][20];
    int zhen[100], doubt[100];
    int last = 0, max = 0 ;
    scanf("%d", &z );
    while( z-- )
    {
           memset(zhen, 0, sizeof(zhen));
           memset(doubt, 0, sizeof(doubt));
           for( i = 1 ; i <= 3 ; i++ )
           {     
                scanf("%s", left[i] );
                scanf("%s", right[i] );
                scanf("%s", com[i] );
           }
           for( i = 1 ; i <= 3 ; i++ )
           {
                if( com[i][0] == 'e' )
                    for( j = 0; j < strlen(left[i]) ; j++ )
                    {
                         zhen[(int)(left[i][j] -64)] = 1;
                         zhen[(int)(right[i][j] -64)] = 1;
                    }
                if( com[i][0] == 'u')
                    for( j = 0 ; j < strlen(left[i]) ; j++ )
                    {
                         doubt[(int)left[i][j]-64]++;
                         doubt[(int)right[i][j]-64]--;
                    }
                if( com[i][0] == 'd')
                    for( j = 0 ; j < strlen(left[i]) ; j++ )
                    {
                         doubt[(int)left[i][j]-64]--;
                         doubt[(int)right[i][j]-64]++;
                    }
           }
           for( i = 1 ; i <= 12 ; i++ )
                if( zhen[i] == 1 )
                    doubt[i] = 0;
           for( i = 1 ; i <= 12 ; i++ )
           {     
                 if( (int)fabs( doubt[i] ) > max )
                 {    
                      max = (int)fabs(doubt[i]);
                      last = i;
                 }
           }
           if( doubt[last] < 0 )
                   printf("%c is the counterfeit coin and it is light.\n", (char)(last + 64) );
           if( doubt[last] > 0 )
                   printf("%c is the counterfeit coin and it is heavy.\n", (char)(last + 64) );
    }
}

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