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 all the characters in S​2​​ from S​1​​. Your task is simply to calculate S​1​​−S​2​​ 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 S​1​​ and S​2​​, respectively. The string lengths of both strings are no more than 10​4​​. 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 S​1​​−S​2​​ in one line.

Sample Input:

They are students.
aeiou

Sample Output:

Thy r stdnts.

具体代码:

getline一套

#include <cstdio>
#include <string>
#include <iostream>
using namespace std;
bool hashtable[120]={false};int main(){string S1;string S2;getline(cin,S1);getline(cin,S2);//因为字符串中有空格所以不用scanfint len1=S1.length();int len2=S2.length();for(int i=0;i<len2;i++){hashtable[S2[i]-'0']=true;}for(int i=0;i<len1;i++){if(hashtable[S1[i]-'0']==false)cout<<S1[i];}return 0;}

1050 String Subtraction (20 分)相关推荐

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

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

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

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

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

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

  5. 【PAT (Advanced Level) Practice】1050 String Subtraction (20 分)

    C/C++中整型数组的下标类型不一定为整型,C C++语言下数组性质与散列有些类似,即散列中的键值对:下标即为关键码,关键码通过散列函数映射得到元素即为值 下标可以为整型,也可以为字符型,简单案例如下 ...

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

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

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

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

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

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

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

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

最新文章

  1. 这个赛车AI不再只图一时爽,学会了考虑长远策略
  2. 并发模型与IO模型梳理
  3. Java锁详解之ReentrantLock
  4. MongoDB 小试牛刀
  5. php 提取登录QQ,php QQ登录
  6. 李飞飞演讲实录 | 云原生数据库2.0:一站式全链路数据管理与服务
  7. Linux嵌入式 -- Bootloader , Uboot
  8. Qt笔记-windows下拷贝文件夹中所有文件
  9. 深度残差收缩网络:(四)注意力机制下的阈值设置
  10. 三星电视开机显示服务器异常,三星液晶电视常见故障及维修方法
  11. session的简介
  12. 春节档影片的成本各是多少?
  13. win10打开蓝牙_WIN10蓝牙不能使用,开启蓝牙后不能识别到其它设备怎么办?
  14. 轻松构建并发送ICMP数据包
  15. 入行这么久? 真正理解了缓存吗
  16. Maven系列(四):Maven内置属性,pom属性
  17. java开源saas项目
  18. win7中如何获取IE8的缓存视频文件
  19. 移动操作系统的优劣及下一代移动系统展望
  20. 【题解】POJ 3069 Saruman's Army(贪心)

热门文章

  1. curl 同时发送多个请求
  2. Nginx负载均衡 后端服务器怎么共享Session 问题
  3. linux之程序包管理器(rpm)
  4. 毕业5年决定你的一生_4
  5. 支持x64的开发工具
  6. sever2008 ad用户和计算机不见,windows-server-2008 – 当我使用Powershell将用户添加到安全组时,它们不会显示在AD中...
  7. 递归算法的基本理解以及基本算法,多行注释详解,适合编程小白,刚接触递归的编程新手
  8. php字符串操作整理,PHP学习之整理字符串
  9. ant 使用java 运行类_用ANT构建java可执行程序
  10. SQL order by的用法