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 ...
随机推荐
- DAY 5模拟赛
DAY 5 廖俊豪神仙出题 T1 最小差异矩阵(a.cpp, a.in, a.out) [题目描述] 有一个 n*m 的矩阵,矩阵的每个位置上可以放置一个数.对于第 i 行,第 i 行的差异定义为该行 ...
- ALV SCRIPTFROM 内容比较全的一个例子
REPORT ZQM_PRT04. *----------------------------------------------------------------------* * TABLES ...
- harbor无法上传镜像解决
报错:[root@bogon harbor]# docker login 192.168.43.65:5000Username (admin): Password: Login Succeeded [ ...
- 龙芯软硬件培训个人总结-day1
第一天主要针对的硬件设计,推他们年底要量产的3A4000+7A1000.这里我只记录下自己关注的几个点. 1,3A4000/3B4000处理器 支持256位向量指令: 对处理器封装进行了优化,不 ...
- Golang基础(7):go的net/rpc用法
一:PRC是什么? RPC(Remote Procedure Call) 远程过程调用,是一个计算通信协议.该协议允许一台计算机上的程序调用另外一台计算机上的程序.远程过程调用就是2个不在同一台计算机 ...
- DateTime相关
1.string数据转成datetime DateTimeFormatter forPattern = DateTimeFormat.forPattern("yyyyMMddHH" ...
- 英特尔® Open Image Denoise 库有助于节省时间,提高质量
在使用光线跟踪增强真实性与沉浸感时,游戏开发人员面临复杂的权衡.为了克服一系列挑战,英特尔创建了使用光线跟踪进行图像渲染的一整套解决方案,包含高性能开源滤波器.该解决方案已发布测试版,被集成至 Uni ...
- #Java学习之路——基础阶段二(第十二篇)
我的学习阶段是跟着CZBK黑马的双源课程,学习目标以及博客是为了审查自己的学习情况,毕竟看一遍,敲一遍,和自己归纳总结一遍有着很大的区别,在此期间我会参杂Java疯狂讲义(第四版)里面的内容. 前言: ...
- Linux文件目录的权限
权限对文件的重要性:(主要是针对文件的内容而言,与文件名没有关系) r: 可读取此文件的实际内容. w: 可以编辑.新增或者修改该文件的内容(但不能删除该文件) x: 该文件具有可以被系统执行的权限. ...
- [转帖]Chrome 错误代码:ERR_UNSAFE_PORT
Chrome 错误代码:ERR_UNSAFE_PORT 2018年07月18日 09:07:50 孤舟听雨 阅读数 182 https://blog.csdn.net/u013043762/artic ...