| ||||||||||
| 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>
#include <string.h>
int main(int argc, char *argv[])
{
int n,i,j,k,l,x,s,m,y;
char a[10000][10000];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s",a[i]);
l=strlen(a[i]);
x=0;
while(a[i][x]!='?')
x++;
if((l-x)%3==0)
m=7;
else if((l-x)%3==1)
m=9;
else
m=3;
if(l==6)
s=(a[i][0]-48)*7+(a[i][1]-48)*3+(a[i][2]-48)*9+(a[i][3]-48)*7+(a[i][4]-48)*3+(a[i][5]-48)*9-(a[i][x]-48)*m;
if(l==7)
s=(a[i][0]-48)*9+(a[i][1]-48)*7+(a[i][2]-48)*3+(a[i][3]-48)*9+(a[i][4]-48)*7+(a[i][5]-48)*3+(a[i][6]-48)*9-(a[i][x]-48)*m;
y=s%10;
y=10-y;
for(j=0;j<=9;j++)
if(((j*m)%10)==y)
break;
a[i][x]=j+48;
}
for(i=0;i<n;i++)
{
printf("Scenario #%d:\n",i+1);
printf("%s\n",a[i]);
printf("\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