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 ...
随机推荐
- faster RCNN(keras版本)代码讲解(3)-训练流程详情
转载:https://blog.csdn.net/u011311291/article/details/81121519 https://blog.csdn.net/qq_34564612/artic ...
- google docker镜像下载
https://anjia0532.github.io/2017/11/15/gcr-io-image-mirror/
- CTF -攻防世界-misc新手区
此题flag题目已经告诉格式,答案很简单. 将附件下载后,将光盘挂到虚拟机启动 使用 strings linux|grep flag会找到一个O7avZhikgKgbF/flag.txt然后root下 ...
- 201703-1 分蛋糕 Java
思路: 注意最后如果剩余蛋糕的重量小于k,也算一个人分到 import java.util.Scanner; public class Main { public static void main(S ...
- java将HSSFWorkbook生成的excel压缩到zip中
思路:1.写入输入流中. 2.将输入流加到ZipOutputStream压缩流中 List<DocumentModel> list = null; try { list = documen ...
- nginx 负载策略
1.轮询(weight=1) 默认选项,当weight不指定时,各服务器weight相同,每个请求按时间顺序逐一分配到不同的后端服务器,如果后端服务器down掉,能自动剔除. upstream bak ...
- not in 优化 NOT EXISTS替代
优化前 SELECT id, loan_id, NAME FROM xw_baoxian_interchange WHERE , , ) , ) AND loan_id NOT IN ( SELECT ...
- HTTP Error 500.30 - ANCM In-Process Start Failure错误。.NET Core
调试.NET Core项目.出现了以下的错误.学网上搞了好久IIS没卵用.然后根据微软的提示,解决了问题. 解决方法: 1. 目标平台换成Any CPU 2.点击工具-获取工具和功能,把下面这个II ...
- 17.3.12----OS模块ya
1---他是一xu个python系统编程的操作模块,可以处理文件和目录这些我们日常手动需要做的操作. import os#导入这个os模块,其实python模块就是C元的包含很多函数的文件 2---o ...
- Innodb-内存架构与特性
参考文档 Innodb特性buffer_pool http://mysql.taobao.org/monthly/2017/05/01/?spm=a2c4e.11153940.blogcont2812 ...