天天看点

PAT B1029 旧键盘

#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;

int main() {
	char a[81], b[81];
	int res[96] = {};      //数组下标为ASCII码,值为0代表未输出过 //下划线'_'的ASCII码为95,并且只输出大写字符,故数组只需开到96
	scanf("%s", a);
	scanf("%s", b);
	int len_a = strlen(a);
	int len_b = strlen(b);
	int i = 0, j = 0;
	while (i < len_a ) {        //不用考虑b字符串是否到头
		if (a[i] == b[j]) {
			i++;
			j++;
		}
		else {
			int tmp;
			if (a[i] >= 'a' && a[i] <= 'z') {   //如果是小写,则转化成大写字母
				tmp = a[i] - 32;
			}
			else {
				tmp = a[i];
			}
			if (res[tmp] == 0) {        //如果这个大写字符未输出过,则输出
				printf("%c", tmp);
				res[tmp]++;     //标记该字符已输出
			}
			i++;
		}
	}
	
}