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 zhucheng at 2005-10-04 16:50:36 on Problem 2629
In Reply To:wa得不行了~~~~~~~~~~~~~~~~~WHO CAN TELL ME WHY!~ Posted by:zwf at 2005-10-04 16:46:08
> #include "stdio.h"
> #include "string.h"
> int main()
> {
> 	char a[10000],b[10000];
> 	int i,flag1[26],flag2[26];
> L1:	while (gets(a))
> 	{	
> 		if (a[0]=='\0') goto L1;
> L2:		gets(b);
> 		if (b[0]=='\0') goto L2;
> 		memset(flag1,0,sizeof(flag1));
> 		memset(flag2,0,sizeof(flag2));
> 		for (i=0;i<strlen(a);i++)
> 			flag1[a[i]-97]=1;
> 		for (i=0;i<strlen(b);i++)
> 			flag2[b[i]-97]=1;
> 		for (i=0;i<26;i++)
> 			if (flag1[i]&&flag2[i]) printf("%c",i+97);
> 		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