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 ...
随机推荐
- 编写检测深度模型测试程序python
参考:https://blog.csdn.net/haoji007/article/details/81035565?utm_source=blogxgwz9 首先从网上下载imagenet训练好的模 ...
- JS向固定数组中添加不重复元素并冒泡排序
向数组{7,20,12,6,25}中添加一个不重复的数字,然后按照从小到大的顺序排列 源代码: <!DOCTYPE html> <html> <head> < ...
- Python说文解字_Python之多任务_04
问:并发.并行.同步.异步.阻塞.非阻塞 答: 并发.并行: 并发是指一个时间段内(不是指的时间点),有几个程序在同一个CPU上运行,但是任意时刻只有一个程序在CPU上运行.对人类的时钟来说1秒钟能干 ...
- Python之路,Day1 - Python基础1 介绍、基本语法、流程控制
本节内容 1.python介绍 2.发展史 3.python 2.x or python 3.x ? 4.python 安装 5.第一个程序 Hello World 程序 6.变量 7.用户输入 8. ...
- Vue-router(5)之 路由的before家族
beforeEach方法 import Vue from 'vue' import Router from 'vue-router' import Son1 from '@/view/New/son1 ...
- 京东云入选2019年度TOP100全球软件案例 新一代服务治理框架加速行业落地
11月14日-17日, 2019TOP100全球软件案例研究峰会(TOP100summit)在北京国家会议中心举办.Top100summit是科技界一年一度的案例研究峰会,每年会秉承"从用户 ...
- 4)栈和队列-->受限线性表
栈和队列叫 受限线性表 只不过他们插入和删除的位置 相对于之前的线性表有了限制 所以叫受限线性表 1)栈-->就是先进后出 2)队列-->先进先出 3)循环链表框图: 4)队列
- MySQL--通过.frm和.ibd对mysql数据恢复
转载:http://bbs.csdn.net/topics/392114182 例如说 现在要恢复user表1.先建立和之前user表一样的表结构.就是执行create table user .... ...
- Java--二维码生成&图片和流转化
package test; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java. ...
- h5-FileReader对象的使用
<!--FileReader对象的使用--> <!--需要及时预览 及时:当用户选择完图片之后就立即进行预览处理--onchange事件 预览:通过文件读取对象的readAsData ...