1084 Broken Keyboard (20 point(s))

本文介绍了一种使用STL(标准模板库)进行字符筛选的方法。通过C++的map和vector,从输入字符串中筛选出未在另一字符串中出现且未被插入过的字符,并以大写形式输出。涉及的主要技术包括STL的map用于记录字符是否存在,vector用于存储结果,以及算法库中的计数函数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

题解

STL的应用。

#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<string>
using namespace std;
map<char, bool> have, insert;
vector<char> res;
string a, b;
int main() {
	cin >> a >> b;
	for(int i = 0; i < b.length(); ++i) have[b[i]] = true;
	for(int i = 0; i < a.length(); ++i) if(!have.count(a[i]) && !insert.count(toupper(a[i]))) {
		insert[toupper(a[i])] = true;
		res.push_back(toupper(a[i]));
	}
	for(int i = 0; i < res.size(); ++i) printf("%c", res[i]);
	return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值