一、技术总结

  1. 这个是使用了一个bool类型的数组来判断该字符是否应该被输出。
  2. 然后就是如果在str2中出现那么就判断为false,被消除不被输出。
  3. 遍历str1如果字符位true则输出该字符。
  4. 还有需要注意的是memset函数是在头文件#include"cstring"中。

二、参考代码:

#include<iostream>
#include<cstring>
using namespace std;
bool hashTable[256];
int main(){
memset(hashTable,false,sizeof(hashTable));
string str1,str2;
getline(cin,str1);
getline(cin,str2);
int len1 = str1.length();
int len2 = str2.length();
for(int i = 0; i < len1; i++){
hashTable[str1[i]] = true;
}
for(int i = 0; i < len2; i++){
hashTable[str2[i]] = false;
}
for(int i = 0; i < len1; i++){
if(hashTable[str1[i]] == true){
cout << str1[i];
}
}
return 0;
}

A1050 String Subtraction (20 分)的更多相关文章

  1. 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 ...

  2. PAT Advanced 1050 String Subtraction (20 分)

    Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be the remaining string after taking ...

  3. 1050 String Subtraction (20分)

    Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be the remaining string after taking ...

  4. PAT练习--1050 String Subtraction (20 分)

    题⽬⼤意:给出两个字符串,在第⼀个字符串中删除第⼆个字符串中出现过的所有字符并输出. 这道题的思路:将哈希表里关于字符串s2的所有字符都置为true,再对s1的每个字符进行判断,若Hash[s1[i] ...

  5. 【PAT甲级】1050 String Subtraction (20 分)

    题意: 输入两个串,长度小于10000,输出第一个串去掉第二个串含有的字符的余串. trick: ascii码为0的是NULL,减去'0','a','A',均会导致可能减成负数. AAAAAccept ...

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

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

  7. pat1050. String Subtraction (20)

    1050. String Subtraction (20) 时间限制 10 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Giv ...

  8. 1050. String Subtraction (20)

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

  9. PAT---1050. String Subtraction (20)

    #include<iostream> #include<string.h> #include<stdio.h> using namespace std; #defi ...

随机推荐

  1. vue 移动端上传图片结合localResizeIMG插件进行图片压缩

    localResizeIMG插件的功能是将图片进行压缩,然后转换成base64传给后台. 首先, npm i lrz -save 然后,再main.js里面引入lrz import lrz from ...

  2. C# 中如何创建异步平行任务?

    解释都在代码里,直接贴代码了: private async void btnStartRequestResource_Click(object sender, EventArgs e) { ShowA ...

  3. JVM的监控工具之jmap

    参考博客:https://www.jianshu.com/p/a4ad53179df3 jmap(Memory Map for Java)命令用于生成堆转储快照(一般称为heapdump或dump文件 ...

  4. Ubuntu 限制 指定端口和IP 访问

    限制端口和IP的时候 要注意别自己登陆不进去了,要不就惨了. 只允许指定的IP访问服务器的指定端口:22 只允许访问的ip: 192.168.1.1 192.168.1.2 192.168.1.3,禁 ...

  5. 使用AvalonEdit实现WPF的Lua编辑器

    原文发布于:https://www.chenxublog.com/2019/07/14/use-avalonedit-make-wpf-lua-editor.html 由于LLCOM里面内置了Lua代 ...

  6. 解决 Windows Server 2008 R2 上 Windows Update 无法失败,提示 8024402F

    1.同步服务器时间 2.打开 services.msc,停止 Windows Update Service 3.手动下载 KB3138615 补丁:https://support.microsoft. ...

  7. jenkins安装后提示localhost 拒绝了我们的连接请求。

    我是用msi文件安装的windows本地 ,安装文件看另外安装的博文. 此问题解决不是第一次安装方案 ,而是第一次安装完,使用也正常,关电脑再次访问的时候提示找不到 ,是因为本地服务没有启动  ,wi ...

  8. 【转】测试开发工程师必备软硬能力&高级测试开发工程师需要具备什么能力?

    对于测试的基本知识,可以查看软件测试相关书籍 对于在公司成为一位优秀的测试开发工程师,我觉得下面这篇文章涉及到的是我们需要的,稍微进行改动https://blog.csdn.net/sinat_210 ...

  9. Jenkins持续集成的应用--基础

    1.测试工程师为什么要掌握持续集成 一个程序员如果想发布一个产品,他需要编码.编译.测试,发布的过程.对于一个企业来说,如果也想发布一个产品的话,同样的也是需要上述的过程,区别在于企业要发布的产品的需 ...

  10. 软工Alpha七天冲刺

    七天冲刺博客: 1.第一篇Scrum冲刺博客 2.第二篇Scrum冲刺博客 3.第三篇Scrum冲刺博客 4.第四篇Scrum冲刺博客 5.第五篇Scrum冲刺博客 6.第六篇Scrum冲刺博客 7. ...