1050 String Subtraction

Given two strings S1 and S2, S=S1−S2 is defined to be the remaining string after taking all the characters in S2 from S1. Your task is simply to calculate S1−S2 for any given strings. However, it might not be that simple to do it fast.

Input Specification:

Each input file contains one test case. Each case consists of two lines which gives S1 and S2, respectively. The string lengths of both strings are no more than 104. It is guaranteed that all the characters are visible ASCII codes and white space, and a new line character signals the end of a string.

Output Specification:

For each test case, print S1−S2 in one line.

Sample Input:

They are students.
aeiou

Sample Output:

Thy r stdnts.

gets函数在PAT编译中不可用,将其改为cin.getline()

#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
using namespace std;char s1[10010];
char s2[10010];
bool hashtable[128]={false};int main()
{cin.getline(s1, 10010);cin.getline(s2, 10010);int len1 = strlen(s1);int len2 = strlen(s2);for (int i = 0; i < len2; i++){hashtable[s2[i]] = true;}for (int i = 0; i < len1; i++){if (!hashtable[s1[i]]){printf("%c",s1[i]);}}
}

1050 String Subtraction相关推荐

  1. PAT甲级1050 String Subtraction:[C++题解]字符串作差

    文章目录 题目分析 朴素算法 hash表优化 题目链接 题目分析 遇到的问题:如何删除下标i的值,我的意思是i后面的需要前移吗?还是有好的解决方法. 笔者想到的是打上标记! string读入一整行的方 ...

  2. 1050 String Subtraction

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

  3. PAT甲级1050 String Subtraction

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

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

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

  5. 【PAT甲级 删除字符串中的指定字符】1050 String Subtraction (20 分) C++

    题目 删除字符串中的另一个字符串包含的所有字符. 可以通过判断两个字符串是否为空,来稍微优化一下运行速度 题解C++ #include<iostream> #include<stri ...

  6. PAT甲级 -- 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 ...

  7. 1050 String Subtraction (20 分)_10行代码AC

    立志用最少的代码做最高效的表达 PAT甲级最优题解-->传送门 Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be ...

  8. PAT:1050. String Subtraction (20) AC

    #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; bool ...

  9. C++ PAT甲级 1050 String Subtraction (20分)

    Given two strings S​1 and S​2, S=S1−S​2is defined to be the remaining string aftertaking all the cha ...

最新文章

  1. 查看LINUX发行版的名称及其版本号
  2. FreeMarker基本语法详解及模板文件的组成(二)
  3. python趣味编程表白_【暖心一笑】Python趣味编程:定时给Ta讲笑话
  4. C#阶乘类,可以精确计算大数的阶乘,10000的阶乘只要1.3秒左右
  5. 【Android 安全】DEX 加密 ( 代理 Application 开发 | 项目中配置 OpenSSL 开源库 | 使用 OpenSSL 开源库解密 dex 文件 )
  6. 小米宋强:生态化大数据平台的深度应用实践
  7. (从零开始java开发) IDEA+MAVEN构建一个webapp骨架项目(解决一直downloading问题)...
  8. 数字签名与HTTPS详解
  9. I.MX6 shutdown by software
  10. 外星人进化_外星人真的比人类强大吗?科学家给出几种猜想,你认同吗?
  11. linux 操作系统级别监控 free命令
  12. 类型多样的3Dmax软件插件素材,速来收藏
  13. Matlab多项式基本运算(1)( polyval和polyvalm的区别)
  14. ES集群报错:master_not_discovered_exception 503
  15. python开头编码cc手_python的编码问题整理
  16. 便签记事本 手机便签记事本app
  17. DMP (Dynamic Movement Primitives) 动态运动基元
  18. C++ 无法打开 源 文件「bits/stdc++.h」//E1696
  19. python新式类c3算法_Python新式类的方法解析顺序MRO与Super
  20. ps -aux | grep 用法

热门文章

  1. 社群运营和用户运营的岗位区别
  2. 最完整的Eclipse插件AmaterasUML的下载安装教程
  3. 黑苹果更新后无法开机的拯救思路
  4. 1分钟解决universal link微信校验不通过
  5. 2022深脑链双周报第105期(02.16-02.28)
  6. 如何进入电脑安全模式
  7. 打印机无法从服务器获取信息,win10系统安装打印机提示无法从Windows Update获取设备列表怎么办...
  8. 最新彩虹Ds模板-Cool模板源码
  9. 测试人生 | (汇总篇)从小团队的业务到独角兽的测开,涨薪超过60%,90后小哥哥凤凰涅槃了
  10. 文本编辑器之kindeditor