1050 String Subtraction (简单题,打表记录)
简单 string 记录 打表
2023-09-11 14:17:55 时间
目录
题目
题目链接:
测试样例
输入样例
They are students.
aeiou
输出样例
Thy r stdnts.
提交结果截图
算法描述
很简单,打表记录每个字符是否包含于S2,在输出时,不输出被记录的字符即可。
带详细注释的源代码
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
string str1, str2;
vector<bool>flag(256, false);//大小为256,都赋值为false,用于标记str1所包含的字符
getline(cin, str2);//按行输入
getline(cin, str1);
for (int i = 0; i < str1.length(); i++)//str1所包含的字符标记为true
flag[str1[i]] = true;
for (int i = 0; i < str2.length(); i++)//依次输出所有未被标记为true的字符
if (!flag[str2[i]])
cout<<str2[i];
return 0;
}
相关文章
- Python运用于数据分析的简单教程
- redis 简单整理——主从拓扑图[二十二]
- 【RF库测试】Encode String To Bytes&Decode Bytes To String& should be string&should be unicode string &should not be string
- 【二叉树】LeetCode 104. 二叉树的最大深度【简单】
- mysql简单的碎片清理脚本
- php之文件上传简单介绍
- 优云automation实践技巧:简单4步完成自动化构建与发布
- redis 简单整理——持久化的问题定位和优化[二十一]
- 【RF库测试】Encode String To Bytes&Decode Bytes To String& should be string&should be unicode string &should not be string
- 【RL-TCPnet网络教程】第38章 TFTP简单文件传输基础知识
- SAP UI5函数节流(Throttle)的一个最简单的例子
- 简单JS代--点击谁添加背景色
- 简单好用,分享 4 款 Pandas 自动数据分析神器
- 简单理解BigDecimal.valueof(Double t)与BigDecimal.valueof(String t)的区别——BigDecimal
- Javascript中String对象的的简单学习
- 一步一步写一个简单通用的makefile(一)
- 在OpenCV里使用最简单方法实现二维码识别
- WPF绘制简单常用的Path(转)
- React简单样例
- OpenCV这么简单为啥不学——2.1、imwrite逐帧保存图片