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 ...
随机推荐
- SpringMVC:提交参数名与接收参数名问题
1.提交的域名称和处理方法的参数名一致 提交数据 : http://localhost:8080/hello?name=111 处理方法 : @RequestMapping("/hello& ...
- selenium登陆qq邮箱页面
from selenium import webdriver driver = webdriver.Chrome() driver.get('https://mail.qq.com/cgi-bin/l ...
- 吴裕雄--天生自然MySQL学习笔记:MySQL 处理重复数据
有些 MySQL 数据表中可能存在重复的记录,有些情况允许重复数据的存在,但有时候我们也需要删除这些重复的数据. 防止表中出现重复数据 可以在 MySQL 数据表中设置指定的字段为 PRIMARY K ...
- 报错:不是GROUP BY 表达式
oracle库中:group by后面必须加上你select后面所查询的所有除聚合函数之外的所有字段. 解决方法:将group by放入子查询中使用或者将select后面的所有查询字段放入group ...
- 20.docker 持久化存储与数据共享
1.image layer 和 container layer 的关系 image layer 是可读的 container layer 是在image layer 之上创建的 一个可读可写层 con ...
- 申请FreeDomain,透过DNS转回自己的Godaddy Cpanel
148.66.136.216这个IP,是我的Cpanel IP. 过了几分钟,这个kkchan.tk就转到Cpanel了. 然后在Cpanel的Addon Domains加上kkchan.tk,那就可 ...
- 题解 P1630 【求和】
题目 发现题解都不够优雅,就自己来一篇 ( 以下除[代码]处代码,其余均为现场手打,如有误请与本蒟蒻联系 ) [分析] 首先,看清楚了,题目是 \(\sum_{i=1}^ai^b\) 的余数 ,而不是 ...
- 201312-1 出现次数最多的数Java
import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Scanner; ...
- 吴裕雄--天生自然 PHP开发学习:表单 - 验证邮件和URL
$name = test_input($_POST["name"]); if (!preg_match("/^[a-zA-Z ]*$/",$name)) { $ ...
- 如何在 main() 执行之前先运行其它函数
摘要:我们知道 C++ 的全局对象的构造函数会在 main 函数之前先运行,其实在 c 语言里面很早就有啦,在 gcc 中可以使用 __attribute__ 关键字指定如下(在编译器编译的时候就绝决 ...