PAT乙题 1029. 旧键盘(20)

2018/01/26 PAT 共 697 字,约 2 分钟
//cpp:
#include <iostream>
#include <algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<ctype.h>
#include<set>
using namespace std;
int main() {
#ifdef LOCAL
	freopen("D:\\datain.txt", "r", stdin);
#endif
	string a, b;
	cin >> a >> b;
	int j = 0;
	set<char> s;
	for (int i = 0; i < b.length(); i++) {
		while (a[j] != b[i]) {
			if(s.find(toupper(a[j]))==s.end())
				printf("%c", toupper(a[j]));
			s.insert(toupper(a[j]));
			//cout << a[j];
			j++;
		}
		j++;
		
		//cout << "++++" << b[i] << endl;
	}
	while (j < a.length()) {
		if (s.find(toupper(a[j])) == s.end())
			printf("%c", toupper(a[j]));
		s.insert(toupper(a[j]));
		//cout << a[j];
		j++;
	}
	return 0;
}

Search

    Table of Contents