Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

也给你改了一下

Posted by c0500448242 at 2005-07-22 10:12:56 on Problem 2498
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator