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

Re:不知咋错了~~郁闷~~

Posted by 61886510 at 2011-07-11 19:34:14 on Problem 2190
In Reply To:不知咋错了~~郁闷~~ Posted by:61886510 at 2011-07-11 19:27:19
> #include<iostream>
> using namespace std;
> int main()
> {
> 	int n,sum,f,i;
> 	char a[20];
> 	while(scanf("%s",a)!=EOF)
> 	{
> 		f=sum=0;
> 		for(i=0;i<10;i++)
> 		{
> 			if(a[i]=='?')
> 			{
> 				n=i;
> 				a[i]=0;
> 				continue;
> 			}
> 			if(a[i]=='X'||a[i]=='x')
> 				a[i]=10;
> 			else
> 				a[i]=a[i]-'0';
> 			sum+=(10-i)*a[i];
> 		}
> 		while(sum%11)
> 		{
> 			sum+=(10-n);
> 			a[n]++;
> 			if(a[n]>10||(n!=9&&a[n]==10))
> 			{
> 				f=1;
> 				break;
> 			}
> 		}
> 		if(f==1)
> 			printf("-1\n");//这忘else了,所以
> 		if(a[n]==10&&!f)
> 			printf("X\n");
> 		else
> 			printf("%d\n",a[n]);//在这又输出了一遍
> 	}
> 	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