PAT Advanced 1050 String Subtraction (20 分)
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 1. 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.
#include <iostream>
using namespace std; int main(){
string s1,s2,res="";
getline(cin,s1);
getline(cin,s2);
for(int i=;i<s1.length();i++){
if(s2.find(s1[i])==s2.npos) res+=s1[i];
}
cout<<res;
system("pause");
return ;
}
PAT Advanced 1050 String Subtraction (20 分)的更多相关文章
- PAT 甲级 1050 String Subtraction (20 分) (简单送分,getline(cin,s)的使用)
1050 String Subtraction (20 分) Given two strings S1 and S2, S=S1−S2 is defined to be t ...
- PAT Advanced 1050 String Subtraction (20) [Hash散列]
题目 Given two strings S1 and S2, S = S1 – S2 is defined to be the remaining string afer taking all th ...
- PAT练习--1050 String Subtraction (20 分)
题⽬⼤意:给出两个字符串,在第⼀个字符串中删除第⼆个字符串中出现过的所有字符并输出. 这道题的思路:将哈希表里关于字符串s2的所有字符都置为true,再对s1的每个字符进行判断,若Hash[s1[i] ...
- 【PAT甲级】1050 String Subtraction (20 分)
题意: 输入两个串,长度小于10000,输出第一个串去掉第二个串含有的字符的余串. trick: ascii码为0的是NULL,减去'0','a','A',均会导致可能减成负数. AAAAAccept ...
- 1050 String Subtraction (20分)
Given two strings S1 and S2, S=S1−S2 is defined to be the remaining string after taking ...
- PAT 解题报告 1050. String Subtraction (20)
1050. String Subtraction (20) Given two strings S1 and S2, S = S1 - S2 is defined to be the remainin ...
- PAT甲级——1050 String Subtraction
1050 String Subtraction Given two strings S1 and S2, S=S1−S2 is defined to be the remain ...
- PAT (Advanced Level) 1050. String Subtraction (20)
简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...
- PAT Advanced 1042 Shuffling Machine (20 分)(知识点:利用sstream进行转换int和string)
Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techn ...
随机推荐
- Mysql 基础操作命令
1,查看mysql的建表语句 show create table tableName; #tableName 库中已存在的表名
- c++ STL -- set和multiset
set和multiset 1.结构 set和multiset会根据特定的排序原则将元素排序.两者不同之处在于,multisets允许元素重复,而set不允许重复. 只要是assignable.copy ...
- windos 启动redis服务端与客户端
服务端:1-win+R 打开命令行2-cd至redis目录,例如 G:\Redis63813-输入 redis-server.exe redis.windows.conf观察是否如图1:至此,已成功: ...
- EventChannel 原生向Flutter传递数据
目的:原生页面主动向Flutter页面传递信息 1 flutter步骤 定义EventChannel static const EventChannel eventChannel = EventCha ...
- leetcode 63 不同路径II
二维数组动态规划,还可以采用一维数组进行动态规划. class Solution { public: int uniquePathsWithObstacles(vector<vector< ...
- 权重随机算法Java实现
权重随机算法在抽奖,资源调度等系统中应用还是比较广泛的,一个简单的按照权重来随机的实现,权重为几个随机对象(分类)的命中的比例,权重设置越高命中越容易,之和可以不等于100: 简单实现代码如下: ? ...
- 解决打开AS多次提示Untrusted Server's certificate问题
解决方法如下: 打开Studio左上角的file—>Setting-->Tools-->Server Certificates ->最后勾上 Accept non-truste ...
- ping一个网段下的所有ip
for /l %i in (1,1,255) do ping -n 1 -w 60 192.168.0.%i | find "Reply" >>d:\pingall.l ...
- GitLab使用小结
对Git和GitLab的使用作一个小结 GitLab基于Git,可以作为团队开发项目使用,因此通常会有一个主分支master和其他分支,因此项目成员中任意一人不能随意push到主分支中,容易引起混乱: ...
- 交换机安全学习笔记 第九~十章 HSRP VRRP
HSRP (Hot Standby Router Protocol) 热备份路由器协议 思科私有 HSRP消息使用UDP 端口号 1985(IPv6时为2029) 使用多播地址 224.0.0.2( ...