L1-011 A-B【团体程序设计天梯赛-练习集】

L1-011 A-B

题要求你计算A−B。不过麻烦的是,A和B都是字符串 —— 即从字符串A中把字符串B所包含的字符全删掉,剩下的字符组成的就是字符串A−B。

输入格式:
输入在2行中先后给出字符串A和B。两字符串的长度都不超过10
4
,并且保证每个字符串都是由可见的ASCII码和空白字符组成,最后以换行符结束。

输出格式:
在一行中打印出A−B的结果字符串。

输入样例:
I love GPLT! It's a fun game!
aeiou
输出样例:
I lv GPLT! It's fn gm!

代码

点击查看代码
#include<iostream>
#define X first
#define Y second
using namespace std;
typedef long long LL;
const int N = 1e6+10;
const char nl = '\n';

int n;
bool cnt[N];

int main(){
    string a,b;
    getline(cin,a); //不忽略空格输入字符串
    getline(cin,b);
    for(auto x:b)cnt[x] = 1;    //char本身就是数字
    for(auto x:a){
        if(!cnt[x])cout << x;
    }
}
posted @ 2023-02-28 15:42  Keith-  阅读(93)  评论(0编辑  收藏  举报