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 xtu716 at 2007-08-08 19:59:21 on Problem 1936
程序1:AC
Problem Id:1936
Memory:216K  Time:0MS
Language:C++  Result:Accepted

#include <stdio.h>
#include <string.h>

char s[100000],t[100000];

void main()
{
	int i,j;
	int len1,len2;

	while(scanf("%s%s",&s,&t)==2)
	{
		len1=strlen(s);
		len2=strlen(t);


		for(i=0,j=0;j<len1 && i<len2;j++)
		{
			while(s[j]!=t[i]&&i<len2)i++;
			i++;
		}
		if(j==len1&&i<=len2)printf("Yes\n");
		else	printf("No\n");
	}
}
程序2:Wrong Answer
Problem Id:1936
Memory:220K  Time:0MS
Language:C++  Result:Wrong Answer

#include <stdio.h>
char s[100000],t[100000];

void main()
{
	int i,j;
	while(scanf("%s%s",&s,&t)==2)
	{
		int sg=0;

		for(i=0,j=0;;j++)
		{
			if(s[j]=='\0')
			{
				sg=1;
				break;
			}
			if(t[i]=='\0')break;
			while(s[j]!=t[i]&&t[i]!='\0')i++;
			i++;
		}
		if(sg==1)printf("Yes\n");
		else	printf("No\n");
	}
}

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