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 lxhgww at 2006-12-15 22:18:30 on Problem 3158
#include<stdio.h>
#include<string.h>

int main()
{
	char s1[201],s2[201],s[201];
	int l1,l2,i,j;
	gets(s1);
	gets(s2);
	l1=strlen(s1);
	l2=strlen(s2);
	if (l1<l2)
	{
		i=l1;
		l1=l2;
		l2=i;
		strcpy(s,s1);
		strcpy(s1,s2);
		strcpy(s2,s);
	}
	for (i=l1;i<l1+l2;i++)
		s1[i]='0';
	for (i=0;i<l1;i++)
	{
		for (j=0;j<l2;j++)
			if (s1[i+j]=='2'&&s2[j]=='2') break;
		if (j==l2)
		{
			if (l2+i<=l1) printf("%d\n",l1);
			else printf("%d\n",i+l2);
			break;
		}
	}
	if (i==l1) 
	{
		for (i=l2-2;i>=0;i--)
		{
			for (j=l2-1;i+j+1-l2>=0;j--)
				if (s1[i+j+1-l2]=='2'&&s2[j]=='2') break;
			if (i+j+1-l2==-1)
			{
				printf("%d\n",l1-i+l2-1);
				break;
			}
		}
		if (i==-1) printf("%d\n",l1+l2);
	}
	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