2094.cpp

来自「这是哈尔滨工业大学acmOJ的源代码」· C++ 代码 · 共 44 行

CPP
44
字号
/*  This Code is Submitted by wywcgs for Problem 2094 on 2005-10-03 at 17:23:25 */ 
#include <stdio.h>
#include <string.h>
#define  min(a,b)  (((a)<(b))?(a):(b))

int main()
{
	int strA[32], strB[32];
	int i, j, p;
	char ch;
	
	while(1) {
		memset(strA, 0, sizeof(strA));
		memset(strB, 0, sizeof(strB));
		while(1) {
			ch = getchar();
			if(ch == EOF) {
				return 0;
			} else if(ch != '\n') {
				strA[ch-'a']++;
			} else {
				break;
			}
		}
		while(1) {
			ch = getchar();
			if(ch != '\n') {
				strB[ch-'a']++;
			} else {
				break;
			}
		}
		for(i = 0; i < 32; i++) {
			p = min(strA[i],strB[i]);
			for(j = 0; j < p; j++) {
				putchar(i+'a');
			}
		}
		putchar('\n');
	}
	
	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?