题意:给出两个字符串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. Jni_Linux_01_转

    1.Linux下JNI的使用(http://www.cnblogs.com/bastard/archive/2012/05/17/2506877.html) Linux下 JNI的使用 学习Andro ...

  2. JNI_Z_06_方法的操作(没有String类型的参数)_父类的同名方法

    1.关键在于: 使用的 method id 是 子类的 还是 父类的,而 父类methodID的获取 必须使用 父类的class对象. 2.VC6(CPP)的DLL代码: #include<st ...

  3. c++ std::find函数

    template <class InputIterator, class T>InputIterator find (InputIterator first,InputIterator l ...

  4. 关于EventBus3.0使用,你看这篇就够了

    作为一枚Android开发者,关于EventBus相信应该都听说过.要是用过就请忽略本文,本文讲得比较基础. 要是没用过,建议你花两分钟看看. 目前EventBus最新版本是3.0,本demo基于3. ...

  5. 第二章 Burp Suite代理和浏览器设置

    Burp Suite代理工具是以拦截代理的方式,拦截所有通过代理的网络流量,如客户端的请求数据.服务器端的返回信息等.Burp Suite主要拦截http和https协议的流量,通过拦截,Burp S ...

  6. Selenium with Python 001 - 安装篇

    Selenium Python bindings 提供了一个简单的API,让你使用Selenium WebDriver来编写功能/校验测试. 通过Selenium Python的API,你可以非常直观 ...

  7. 遍历jsonArray和jsonObject

    遍历jsonArray String str = "[{name:'a',value:'aa'},{name:'b',value:'bb'},{name:'c',value:'cc'}]&q ...

  8. jenkins集成maven实现自动化接口测试

    当时领导让研究这个,就总结了一个文档,现在记录在这里,给自己留个备份. 1.安装jenkins 地址http://updates.jenkins-ci.org/download/war/ 安装mave ...

  9. LeetCode OJ:Search Insert Position(查找插入位置)

    Given a sorted array and a target value, return the index if the target is found. If not, return the ...

  10. 在ubuntu16.04上安装php7 mysql5.7 nginx1.10并支持http2

    安装nginx 首先更新软件包 并且安装nginx sudo apt-get update sudo apt-get install nginx 开放防火墙配置 sudo ufw allow 'Ngi ...