PAT甲级——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.
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
// freopen("C://坚果云//算法//String Subtractionin.txt","r",stdin);
// freopen("C://坚果云//算法//String Subtractionout.txt","w",stdout);
bool b[1000];
string a,c;
getline(cin,a);
getline(cin,c);
for(int i=0;i<1000;i++)
{
b[i]=true;
}
for(int j=0;j<c.length();j++)
{
b[c[j]]=false;
}
for(int j=0;j<a.length();j++)
{
if(b[a[j]]==true)
{
printf("%c",a[j]);
}
}
// fclose(stdin);
// fclose(stdout);
return 0;
}
PAT甲级——1050 String Subtraction的更多相关文章
- 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 甲级 1050 String Subtraction
https://pintia.cn/problem-sets/994805342720868352/problems/994805429018673152 Given two strings S~1~ ...
- PAT Advanced 1050 String Subtraction (20 分)
Given two strings S1 and S2, S=S1−S2 is defined to be the remaining string after taking ...
- PAT甲级——A1050 String Subtraction
Given two strings S1 and S2, S=S1−S2 is defined to be the remaining string after taking ...
- 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)
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 (20 分) Given two strings S1 and S2, S=S1−S2 is defined to be t ...
- pat 1050 String Subtraction(20 分)
1050 String Subtraction(20 分) Given two strings S1 and S2, S=S1−S2 is defined to be the ...
随机推荐
- zookeeper基础教程
一.关于zookeeper Zookeeper 作为一个分布式的服务框架,主要用来解决分布式集群中应用系统的一致性问题,它能提供基于类似于文件系统的目录节点树方式的数据存储, Zookeeper 作用 ...
- Sequence Models Week 3 Trigger word detection
Trigger Word Detection Welcome to the final programming assignment of this specialization! In this w ...
- 个人网站一步一步搭建——(10)后台登陆dome
Service+ui+dto架构 AJAX 方式登陆小DEMO 后面的.得配合vue 做后台管理了... 还是一个个dome做
- 从结构和数字看OO——面向对象设计与构造第一章总结
不知不觉中,我已经接触OO五周了,顺利地完成了第一章节的学习,回顾三次编程作业,惊喜于自身在设计思路和编程习惯已有了一定的改变,下面我将从度量分析.自身Bug.互测和设计模式四个方向对自己第一章的学习 ...
- ES6 之 数值扩展
1.ES5 // Number类型重写了valueOf() toLocaleString() toString('进制')方法 let a = 10 console.log(a.valueOf()); ...
- SQL基础教程(第2版)第6章 函数、谓词、CASE表达式:6-2 谓词
● 谓词就是返回值为真值的函数. ● 可以将子查询作为IN和EXISTS的参数. 本节将会和大家一起学习 SQL 的抽出条件中不可或缺的工具——谓词(predicate).例如, =. <. & ...
- UML-状态机图和建模
1.目标:如何画状态机图 2.定义:描述某个对象的状态.感兴趣的事件.以及对象响应该事件的行为. 转换:用箭头表示 状态:用圆角矩形表示 事件:指的是一件值得注意的事情的发生.如:拿起电话. 当事件“ ...
- Block实现代理/通知效果
例子1:A控制器->跳转—>B控制器 , 假设想从B控制器回传数组给A控制器 实现:B控制器.h文件定义一个block参数,.m文件执行block,A控制器设置block内容 B.h文件/ ...
- 关于debug模式下对象toString报空指针的问题。Method threw 'java.lang.NullPointerException' exception. Cannot evaluate cn.gooday.jsh.service.common.dto.RestControllerResult.toString()
这个如果debug的时候可以一步步走到正常return或者运行的时候有正确返回值.说明代码是没问题的. 出现这个的原因是dto对象里有一些字段查出来是空的,或者这个字段本来在dto里就是冗余字段. 因 ...
- softmax和分类模型
softmax和分类模型 内容包含: softmax回归的基本概念 如何获取Fashion-MNIST数据集和读取数据 softmax回归模型的从零开始实现,实现一个对Fashion-MNIST训练集 ...