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 t,i,p,len,j,sum; char input[10]; cin>>t; for (i=1;i<=t;++i) { sum=0; cin>>input; len=strlen(input)-1; for (j=len;j>=0;--j) { if (input[j]=='?') { p=j; } else { if ((len-j)%3==0) { sum+=(input[j]-'0')*9; } if ((len-j)%3==1) { sum+=(input[j]-'0')*3; } if ((len-j)%3==2) { sum+=(input[j]-'0')*7; } } } sum%=10; if ((len-p)%3==0) { for (j=0;j<10;++j) { if (j*9%10+sum==10) { input[p]=j+'0'; } } } if ((len-p)%3==1) { for (j=0;j<10;++j) { if (j*3%10+sum==10) { input[p]=j+'0'; } } } if ((len-p)%3==2) { for (j=0;j<10;++j) { if (j*7%10+sum==10) { input[p]=j+'0'; } } } cout<<"Scenario #"<<i<<":\n"<<input<<"\n"<<endl; } system("pause"); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator