Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
囧哇~还望指教哪里错了...#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator