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 |
大哥大姐们,帮我看看吧。十分不解为什么老是WA啊。#include<iostream.h> int p(char a[]) { int i,j,k,sum=0,s=0; for(i=0;i<10;i++)//求和 { if(a[i]=='?') { k=i; } else { if(a[i]!='X')sum+=(10-i)*(int)(a[i]-'0'); else sum+=(10-i)*10; } } for(i=0;i<10;i++)//算?的值 { s=sum+(10-k)*i; if(s%11==0) { return i;//返回?的值 break; } } return -1; } void main(void) { char a[20]; cin.getline(a,20) int k=0; k=p(a); if(k==-1)cout<<-1<<endl; else cout<<k<<endl; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator