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 wc171170 at 2008-07-10 01:21:25 on Problem 2498
#include<iostream>
using namespace std;
int main(void)
{
	int n,i;
	char num[8];
	int sum;
	int j,p,l;
	const int map[]={9,3,7};
	const int Map[3][9]={
		{9,8,7,6,5,4,3,2,1},
		{7,4,1,8,5,2,9,6,3},
		{3,6,9,2,5,8,1,4,7}
	};
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>num;
		l=strlen(num);
		sum=0;
		for(j=0;j<l;j++)
			if(num[j]=='?')
				p=j;
			else
				sum=(sum+(num[j]-'0')*map[(l-j-1)%3])%10;
		num[p]=Map[(l-p-1)%3][9-sum]+'0';
		cout<<"Scenario #"<<i<<":"<<endl;
		cout<<num<<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