题意:给出两个字符串s1和s2,在s1中删去s2中含有的字符。

思路:注意,因为读入的字符串可能有空格,因此用C++的getline(cin,str)。PAT系统迁移之后C语言中的gets()函数被禁用了。

代码:

#include <iostream>
#include <string>
using namespace std;
int main()
{
    string str1,str2;
    getline(cin,str1);
    getline(cin,str2);
    ]={false};//needDeleted[ch]为true表示字符ch应当删去
    for(auto ch:str2) needDeleted[ch]=true;
    for(auto ch:str1){
        if(needDeleted[ch]) continue;//遇到需要删去的字符不输出
        else cout<<ch;
    }
    ;
}

1050 String Subtraction的更多相关文章

  1. PAT 解题报告 1050. String Subtraction (20)

    1050. String Subtraction (20) Given two strings S1 and S2, S = S1 - S2 is defined to be the remainin ...

  2. PAT 1050 String Subtraction

    1050 String Subtraction (20 分)   Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be t ...

  3. 1050 String Subtraction (20 分)

    1050 String Subtraction (20 分) Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be the ...

  4. pat 1050 String Subtraction(20 分)

    1050 String Subtraction(20 分) Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be the ...

  5. PAT 甲级 1050 String Subtraction (20 分) (简单送分,getline(cin,s)的使用)

    1050 String Subtraction (20 分)   Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be t ...

  6. PAT甲级——1050 String Subtraction

    1050 String Subtraction Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be the remain ...

  7. 1050. String Subtraction (20)

    this problem  is from PAT, which website is http://pat.zju.edu.cn/contests/pat-a-practise/1050. firs ...

  8. PAT (Advanced Level) 1050. String Subtraction (20)

    简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...

  9. PAT甲题题解-1050. String Subtraction (20)-水题

    #include <iostream> #include <cstdio> #include <string.h> #include <algorithm&g ...

  10. PAT 甲级 1050 String Subtraction

    https://pintia.cn/problem-sets/994805342720868352/problems/994805429018673152 Given two strings S~1~ ...

随机推荐

  1. ArcEngine 坐标系转换

    /// <summary> /// 地理坐标系 转 投影坐标系 /// </summary> /// <param name="x"></ ...

  2. css文本(教程)

    1.text-transform --文本转换 定义文本的大小写状态,此属性对中文无意义 取值:capitalize | uppercase | lowercase | none | inherit ...

  3. Educational Codeforces Round 23D

    给n个数求每个子区间的价值,区间的价值是最大值-最小值 套路题= =,分别算最大值和最小值的贡献,用并查集维护,把相邻点连一条边,然后sort,求最大是按边价值(两个点的最大价值)小的排,求最小是按最 ...

  4. HDU-4510-日期

    http://acm.hdu.edu.cn/showproblem.php?pid=4510 小Q系列故事——为什么时光不能倒流 Time Limit: 300/100 MS (Java/Others ...

  5. [转载]java开发实现word在线编辑及流转

    OA公文流转系统主要用于处理企业日常工作中内外部的各种公文,包括了公文的拟稿.审批.传阅.公告.归档,多层上级可以对下级撰写的公文进行逐级审批或修改,待最高级人员确认无误后即可进行核稿和发文等操作,最 ...

  6. 如何使用google搜索

    作者:崔凯链接:https://www.zhihu.com/question/20161362/answer/14180620来源:知乎著作权归作者所有,转载请联系作者获得授权. 搜索引擎命令大全! ...

  7. 《Scala入坑笔记》缘起 3天就搞了一个 hello world

    有小伙伴向我咨询 play framework 的问题,我就想了解一下 play framework ,按照官方的文档,要使用 SBT 安装,就掉进了 SBT 的坑. 第一坑:国外仓库太慢 安装完成后 ...

  8. jQuery attr 与 prop 区别最简单分析

    比较经典的解释: 在处理html元素本身就带有的固有属性时,使用prop方法,对于html元素中,我们自己定义的dom属性时,使用attr方法. 而咱自己的理解是: attr会忠实的获取设置dom标签 ...

  9. Http基础(记忆笔记)

    地址解析:http://localhost.com:8080/index.htm 协议名:Http 主机名:localhost.com 端口:8080 对象路径:/index.htm 通过域名解析lo ...

  10. BigDecimal的用法

    一.简介 Java在java.math包中提供的API类BigDecimal,用来对超过16位有效位的数进行精确的运算.双精度浮点型变量double可以处理16位有效数.在实际应用中,需要对更大或者更 ...