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 luketyg at 2008-11-11 13:34:53 on Problem 2190
#include "iostream"
using namespace std;
int main()
{
	char book[11];
	int sum=0,i,k,j=0;
	cin>>book;
	for(i=0;i<10;i++)
	{
		if(book[i]!='?')
		{
			if(book[i]=='X')
				book[i]=10+'0';
			sum+=(10-i)*(book[i]-'0');
		}
		else k=i;
	}
	if(k==9)j=1;
	for(i=0;i<=9+j;i++)
		if(((10-k)*i+sum)%11==0)break;
	if(k==9 && i==10)cout<<"X"<<endl;
	else if(i==10)cout<<-1<<endl;
	else cout<<i<<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