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.

3分:

getchar()把第一个字符读取了

#include <iostream>
#include <string>
using namespace std;string s1, s2;
bool asc[256] = {false}; int main()
{getline(cin,s1);getchar();getline(cin,s2);int len1 = s1.length(), len2 = s2.length();for(int i = 0; i < len2; i++){asc[s2[i]] = true;}for(int i = 0; i < len1; i++){if(asc[s1[i]] == true) continue;else printf("%c",s1[i]);}return 0;
}

20分:

#include <iostream>
#include <string>
using namespace std;string s1, s2;
bool asc[256] = {false}; int main()
{getline(cin,s1);getline(cin,s2);int len1 = s1.length(), len2 = s2.length();for(int i = 0; i < len2; i++){asc[s2[i]] = true;}for(int i = 0; i < len1; i++){if(asc[s1[i]] == true) continue;else printf("%c",s1[i]);}return 0;
}

PAT甲级 -- 1050 String Subtraction (20 分)相关推荐

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

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

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

  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. 1050 String Subtraction (20 分)_10行代码AC

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

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

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

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

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

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

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

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

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

  9. 【PAT甲级】11077 Kuchiguse (20 分) Java

    题目 Java题解(最后一个测试用例没通过) import java.io.BufferedReader; import java.io.IOException; import java.io.Inp ...

最新文章

  1. 您尝试打开的文件_您是否尝试过重新打开软件团队的身份?
  2. 微服务框架-Spring Cloud简介(一)
  3. get,put,post,delete含义与区别
  4. java中后端拼接字符串返回前台页面换行显示
  5. Java NIO系列教程(七) FileChannel
  6. JQuery实现表格行当复制
  7. php date时间本地化问题
  8. wxWidgets:操纵杆 Joystick示例
  9. poj 3082多边形相交 'Roid Rage
  10. response.setHeader各种用法 .
  11. linux 7修改yum源,CentOS 7修改yum源为阿里源
  12. 吴颖二:12.27 什么是现货,如何操作才能盈利
  13. Akka Remote Actor_简单示例二
  14. QT表格QTableWidget在win10下纵横表头无分隔线的问题
  15. 论外挂入门(辅助入门)图色辅助与内存辅助的优与弊
  16. 如何刷访问量 的详细介绍
  17. kubectl管理多个集群配置
  18. Android | Sensor.TYPE_ORIENTATION被废弃后的解决办法
  19. 原则与思维模型--《思维模型》2
  20. 用python爬取微博评论对鹿晗、关晓彤微博进行情感分析

热门文章

  1. 关于寻路算法的一些思考(4):A* 算法的变体
  2. cocos2d-x初探学习笔记(7)--CCProgressTimer
  3. C语言程序设计 | 打印一个n行的菱形
  4. 一文讲懂什么是三层交换机、网关、DNS、子网掩码、MAC地址
  5. 如果我是面试官,我会问你 Spring 那些问题?
  6. 以高并发著称的 Go 如何与 MySQL 搭档应对千亿级数据?
  7. 【WebRTC专场】WebRTC的下个10年,又会有怎样的惊喜?
  8. Google Duo采用WaveNetEQ填补语音间隙
  9. OIL + VCache如何改善Facebook视频延迟 并减少存储和计算开销?
  10. 以“用户播放行为与体验”为核心的视频服务质量优化