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 |
也给你改了一下In Reply To:我的那儿错了? Posted by:Zain at 2005-07-22 10:01:42 //这个错得有点"难看" #include <iostream> #include <string> using namespace std; int main() { int max,T,n,i,j,flag,ans,k=1; string s; cin>>T; while(T--){ cin>>s; for(i=0;i<s.length();++i){ if(s[i]=='?'){ ans=i; break; } } for(j=0;j<10;++j){ if(s.length()%3==1) flag=9; else if(s.length()%3==2) flag=3; else flag=7; max=0; s[ans]=j+'0'; for(i=0;i<s.length();++i){ max+=(int(s[i]-'0'))*flag; if(flag==9) flag=7; else if(flag==7) flag=3; else flag=9; } if(max%10==0) break; } cout<<"Scenario #"<<k++<<':'<<endl; if(max%10==0) cout<<s<<endl; cout<<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