题意:给出两个字符串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. JSON01_资料

    1. 资料网址: http://blog.csdn.net/vincent_czz/article/details/7333977 http://blog.csdn.net/huangwuyi/art ...

  2. qtjambi_ZC

    loadJambiJniLibrary --> loadLibrary --> loadNativeLibrary --> loadLibrary_helper class QApp ...

  3. define用于条件编译

    格式: #ifndef _test.h_ //这里放不想被重复包含的代码 #define _test.h_ #endif define用于条件编译的意思是不想让头文件重复编译,头文件重复编译会造成的结 ...

  4. NSNumber 与NSValue

    NSNumber与NSValue关系与作用 .由于集合里只能存放对象,不可以存放基本数据类型,所以我们有时候需要讲一些对象比如基本数据类型,结构体等存到NSDictionary NSArray中,我们 ...

  5. 智课雅思词汇---二十五、形容词后缀-ate-fic-ose-ulent-olent-ous-ulous-y

    智课雅思词汇---二十五.形容词后缀-ate-fic-ose-ulent-olent-ous-ulous-y 一.总结 一句话总结: 1.形容词后缀-ate(determinate)? determi ...

  6. 第11章:最长公共子序列(LCS:Longest Common Subsequence)

    方法:动态规划 <算法导论>P208 最优子结构 + 重叠子问题 设xi,yi,为前i个数(前缀) 设c[i,j]为xi,yi的LCS的长度 c[i,j] = 0 (i ==0 || j ...

  7. yii2: oralce中文,有的汉字是2个字节,有的汉字是3个字节

    yii2: oralce中文,有的汉字是2个字节,有的汉字是3个字节 请用mb_substr转成1个英文字节

  8. Solr工具类

    import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.spr ...

  9. 编译android源码中的icu4c

    在external/icu4c/studata/readme.txt,里面有修改icu4c中资源的编译方法 # 具体步骤(可复制下面命令,直接运行): # 1)新增或者修改external/icu4c ...

  10. JSP的三大指令

    三大指令:page指令.include指令和taglib指令. page指令: * import:等同与import语句   <%@ page import="java.util.*& ...