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 luxudong at 2010-08-04 17:27:04 on Problem 2498
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{
	int n,i,j,k,l,x,s,m,y;
	char a[10000][10000];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",a[i]);
		l=strlen(a[i]);
		x=0;
		while(a[i][x]!='?')
			x++;
		if((l-x)%3==0)
			m=7;
		else if((l-x)%3==1)
			m=9;
		else
			m=3;
		if(l==6)
			s=(a[i][0]-48)*7+(a[i][1]-48)*3+(a[i][2]-48)*9+(a[i][3]-48)*7+(a[i][4]-48)*3+(a[i][5]-48)*9-(a[i][x]-48)*m;
		if(l==7)
			s=(a[i][0]-48)*9+(a[i][1]-48)*7+(a[i][2]-48)*3+(a[i][3]-48)*9+(a[i][4]-48)*7+(a[i][5]-48)*3+(a[i][6]-48)*9-(a[i][x]-48)*m;
		y=s%10;
		y=10-y;
		for(j=0;j<=9;j++)
		if(((j*m)%10)==y)
			break;
		a[i][x]=j+48;
	}	
	for(i=0;i<n;i++)
	{
		printf("Scenario #%d:\n",i+1);
		printf("%s\n",a[i]);
		printf("\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