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 actest at 2007-02-03 10:56:41 on Problem 2498
#include<stdio.h>
#include<iostream.h>
#include<string.h>
main(){
	int n,i,factors[7]={9,3,7,9,3,7,9},sum,set,ii;
	char a[8];
	cin>>n;
	for(int j=1;j<=n;j++){
		sum=0;
		gets(a);
		for(i=strlen(a)-1;i>=0;i--){
			if(a[i]=='?'){
				ii=i;
				set=factors[strlen(a)-i-1];
				continue;
			}
			else sum+=factors[strlen(a)-i-1]*(a[i]-'0');
		}
		for(i=0;i<=9;i++){
			if((10-sum%10)==(i*set)%10){
				a[ii]=i+'0';
				break;
			}
			else continue;
		}
		cout<<"Scenario #"<<j<<":"<<endl;
		puts(a);
		cout<<endl;
	}
	return 1;
}

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