| ||||||||||
| 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 | |||||||||
为什么同样的代码C++能AC 但是C 就不行呢????????????#include<stdio.h>
int main(){
int i,j,m,k,sum,index;
bool Find;
char a[20];
while( gets(a)){
i=0;
k=10;
sum=0;
Find = false;
while(a[i]!='\0'){
if(a[i]=='?'){
index = i;
}else if(a[i]=='X'){
sum += 10;
}else {
sum += (a[i]-'0')*k;
}
k--;
i++;
}
if(index!=9){
for(j=0;j<=9;j++){
if((sum+(10-index)*j)%11==0){
printf("%d\n",j);
Find = true;
break;
}
}
if (Find == false){
printf("-1\n");
}
}else {
m = sum%11;
if(m==0)
printf("0\n");
else{
if(m!=1)
printf("%d\n",11-m);
else
printf("X\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