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

大哥大姐们,帮我看看吧。十分不解为什么老是WA啊。

Posted by liulaisheng at 2005-10-09 19:23:29 on Problem 2190
#include<iostream.h>

int p(char a[])
{
	int i,j,k,sum=0,s=0;
		for(i=0;i<10;i++)//求和
		{
			if(a[i]=='?')
			{
				k=i;
			}
			else
			{
				if(a[i]!='X')sum+=(10-i)*(int)(a[i]-'0');
				else sum+=(10-i)*10;
			}
		}
	
		for(i=0;i<10;i++)//算?的值
		{
			s=sum+(10-k)*i;
		
				if(s%11==0)
				{
					return i;//返回?的值
					break;
				}
			
		}
	return -1;
}
void main(void)
{
	char a[20];
	cin.getline(a,20)
	
	int k=0;
	k=p(a);
	if(k==-1)cout<<-1<<endl;
	else cout<<k<<endl;
	
}


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