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 hqvip at 2009-04-17 12:42:38 on Problem 2498
#include <stdio.h>
int main()
{
    int n,i,j,k,a[8],mul[3]={9,3,7},len,sum,flag,flag1;
    char p[10];
    scanf("%d",&n);
    {  getchar();
       for(i=0;i<n;i++)
       {
          gets(p);
          printf("Scenario #%d:\n",i+1);
          for(j=0;j<10&&p[j]!='\0';j++)
             if(p[j]!='?')
                a[j]=p[j]-'0';
             else
                a[j]=-1;  
          for(len=j,sum=0,k=0,j=len-1;j>=0;j--)
          {
             if(a[j]>-1)
                sum+=a[j]*mul[k];
             else
             {
                flag=j;
                flag1=k;
             }
             k++;
             k%=3;             
          }
          if(sum%10)
             for(k=1;k<10;k++)
                if((k*mul[flag1]+sum)%10==0)
                {
                   a[flag]=k;
                   break;
                }
          else
             a[flag]=0;
          for(k=0;k<len;k++)
             printf("%d",a[k]);
          printf("\n\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