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> #include<cstring> using namespace std; int main() { int n,b[10],i,j,k,t,len,x,z; char d[10]; scanf("%d",&n); for(i=1;i<=4;i++) { int sum=0,s; scanf("%s",d); len=strlen(d); for(j=len-1;j>=0;j--) { if(d[j]>='0'&&d[j]<='9') { b[j]=d[j]-'0'; if((len-j)%3==1) sum+=b[j]*9; if((len-j)%3==2) sum+=b[j]*3; if((len-j)%3==0) sum+=b[j]*7; } else { t=j; if((len-j)%3==1) z=9; if((len-j)%3==2) z=3; if((len-j)%3==0) z=7; } } for(x=0;x<=9;x++) { s=sum; s+=x*z; if(s%10==0) break; } cout<<"Scenario #"<<i<<":"<<endl; for(k=0;k<len;k++) { if(k==t) printf("%d",x); else printf("%d",b[k]); } cout<<endl<<endl<<endl; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator