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 main() { int a[7]={9,7,3,9,7,3,9}; int b[6]={7,3,9,7,3,9}; char c[8]; long int n,i=0,j,m,q,k,sum=0; cin>>n; while(i<n) { cin>>c; for(j=0;j<8;j++) { if(c[j]=='?') q=j; if(c[j]==0) { m=j;break;} } if(m==7) { for(j=0;j<7;j++) { if(c[j]=='?')continue; sum+=a[j]*(c[j]-'0'); } if(q==0||q==3||q==6) { for(k=0;;k++) if((sum+9*k)%10==0) { c[q]=k+'0';break; } } if(q==1||q==4) { for(k=0;;k++) if((sum+7*k)%10==0) { c[q]=k+'0';break; } } if(q==2||q==4) { for(k=0;;k++) if((sum+3*k)%10==0) { c[q]=k+'0';break; } } sum=0; } if(m==6) { for(j=0;j<6;j++) { if(c[j]=='?')continue; sum+=b[j]*(c[j]-'0'); } if(q==0||q==3) { for(k=0;;k++) if((sum+7*k)%10==0) { c[q]=k+'0';break;} } if(q==1||q==4) { for(k=0;;k++) if((sum+3*k)%10==0) { c[q]=k+'0';break; } } if(q==2||q==5) { for(k=0;;k++) if((sum+9*k)%10==0) { c[q]=k+'0';break; } } sum=0; } cout<<"Scenario #"<<i+1<<":"<<endl; cout<<c<<endl<<endl; i++; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator