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<iostream> using namespace std; int main() { int n,sum,f,i; char a[20]; while(scanf("%s",a)!=EOF) { f=sum=0; for(i=0;i<10;i++) { if(a[i]=='?') { n=i; a[i]=0; continue; } if(a[i]=='X'||a[i]=='x') a[i]=10; else a[i]=a[i]-'0'; sum+=(10-i)*a[i]; } while(sum%11) { sum+=(10-n); a[n]++; if(a[n]>10||(n!=9&&a[n]==10)) { f=1; break; } } if(f==1) printf("-1\n"); if(a[n]==10&&!f) printf("X\n"); else printf("%d\n",a[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