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 qiqilrq at 2007-05-09 20:11:58 on Problem 2498
In Reply To:贴代码了 Posted by:qiqilrq at 2007-05-09 20:02:15
#include <stdio.h>
#include <string.h>
int F[3]={9, 3 ,7};
char id[9];
int sum;
int main()
{
	int i, j, T, que, len;scanf("%d", &T);
	for(i=1; i<=T; i++){
		scanf("%s", id);
		len=strlen(id);
		sum=0;
		for(j=0; j<len; j++) {
			if(id[j]=='?') que=j;
			else sum+=(int)(id[j]-'0') * F[((len-j-1)%3)];
		}
		sum%=10; 
		sum=10-sum;//~~~~~~~~~~~~~~~~~~~~此处sum可能为10!
		for(j=0; j<10; j++)
			if( (j*F[((len-que-1)%3)])%10 == sum ) break;
		id[que]=(char)('0'+j);
		printf("Scenario #%d:\n%s\n\n", i, id);

	}//end for
	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