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 |
Re:不知咋错了~~郁闷~~In Reply To:不知咋错了~~郁闷~~ Posted by:61886510 at 2011-07-11 19:27:19 > #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");//这忘else了,所以 > 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