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

why Output Limit Exceed?(程序入内)

Posted by K208 at 2005-10-26 13:47:47 on Problem 2629
#include <stdio.h>
#include <string.h>

int min(int x , int y)
{
	return x > y ? y : x;
}

int main()
{
int num1[26] , num2[26];
char s[2010] , i , j;

	while (gets(s))
	{
		//if (s[0] == 0) break;
		i = 0;
		memset(num1 , 0 , sizeof(num1));
		while (s[i] > 0) {if ((s[i] >= 'a') && (s[i] <= 'z')) num1[s[i] - 'a'] ++; i ++;}
		gets(s);
		i = 0;
		memset(num2 , 0 , sizeof(num2));
		while (s[i] > 0) {if ((s[i] >= 'a') && (s[i] <= 'z')) num2[s[i] - 'a'] ++; i ++;}
		for (i = 0; i < 26; i ++)
			for (j = 0; j < min(num1[i] , num2[i]); j ++)
				printf("%c" , i + 'a');
		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