题意:给出两个字符串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. javascript异步编程的几种方法

    目前工作中用的比较多的异步模式编程有如下几种方法 一 回调函数 这是异步编程最基本的方法,假设有两个函数f1和f2,后者等待前者的执行结果 f1(); f2(); 如果f1是一个很耗时的任务,可以考虑 ...

  2. 英语发音规则---A字母

    英语发音规则---A字母 一.总结 一句话总结:本文所有//的音标为英音音标,[]的音标为美音音标 1.A在开音节中发/eɪ/ [e]? age /eɪdʒ/ [edʒ] 年龄 ape /eɪp/ [ ...

  3. MailJobUtils 发送邮件

    import java.util.List; import java.util.Properties; import javax.annotation.Resource; import javax.m ...

  4. is(':visible')

    .end()为结束前面处理函数,返回到最初的元素 .next()为此元素的下一个元素,可以再加上.next()表示下下一个元素,以此类推 :visible 选择器选取每个当前是可见的元素.语法:$(& ...

  5. 【nyoj-1274】信道安全(SPFA)

    题目链接:http://acm.nyist.edu.cn/JudgeOnline/problem.php?pid=1274 题目描述 Alpha 机构有自己的一套网络系统进行信息传送.情报员 A 位于 ...

  6. 在VMware永久修改网

    如果想要永久性设置固定的IP地址,需要通过编辑网卡配置文件实现: 现在使用VI编辑器打开配置文件. # vi /etc/sysconfig/network-scripts/ifcfg-eth0 虽然直 ...

  7. Android移动端网络优化

    介绍下针对移动端的网络优化,不限于 Android,同样适用于 iOS 和 H5 本文为性能优化系列第四篇,目前性能调优专题已完成以下部分: 性能优化总纲——性能问题及性能调优方式 性能优化第四篇—— ...

  8. Agilent RF fundamentals (3)- TX and RX

    1Create carrier:谐振器,如433.92Mhz LC谐振 (频偏控制) 2Add data to carrier 加载数据 3Amplify to broadcast :放大器,如NPN ...

  9. [JS学习笔记]Javascript事件阶段:捕获、目标、冒泡

    当你在浏览器上点击一个按钮时,点击的事件不仅仅发生在按钮上,同时点击的还有这个按钮的容器元素,甚至也点击了整个页面. 事件流 事件流描述了从页面接收事件的顺序,但在浏览器发展到第四代时,浏览器开发团队 ...

  10. android Handler的使用(二)

     Handler的使用(二) 一. Handler与线程的关系 Handler在默认情况下,实际上它和调用它的Activity是处于同一个线程的. 例如在Handler的使用(一)的示例1中,虽然 ...