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 2010302447 at 2012-07-06 11:20:43 on Problem 1302
#include<stdio.h>
#include<string.h>
char c[20];
int a[20];
int sum(int k)
{
	int x,sum=0;
	for(x=k+1;x<strlen(c);x++)
		if(a[x]!=0)
			sum++;
		return sum;
}
void change(int m)
{
	int j;
	if(m>=strlen(c))
		for(j=0;j<strlen(c);j++)
		{
			if(a[j]==2)
				if(sum(j)>9)
				c[j]=sum(j)%10+48;
				else
				c[j]=sum(j)+48;
			else;
		}
	else
		if(c[m]>='A'&&c[m]<='Z')//字母
		{
			a[m]=2;
			change(m+1);
		}
		else
			if(c[m]>='1'&&c[m]<='9')//数字
			{
				c[m]=c[m]-1;
				a[m]=1;
				if(m+c[m]-'0'+1>=strlen(c))
					change(m+1);
				else
					change(m+c[m]-'0'+1);
			}
			else
				if(c[m]=='0');//0不变
}
void init()
{
	int i;
	for(i=0;i<20;i++)
	{
		a[i]=0;
		c[i]=0;
	}
}
int main()
{

	int n;
	char b[20];
	while(scanf("%s %d",c,&n)&&strcmp(c,"ENDOFINPUT"))
	{
		getchar();
		init();
		gets(c);
		if(c[0]!='0')
		change(0);
		scanf("%s",b);
		puts(c);
	}
	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