1050 String Subtraction

Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be the remaining string after taking all the characters in S​2​​ from S​1​​. Your task is simply to calculate S​1​​−S​2​​ 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 S​1​​ and S​2​​, respectively. The string lengths of both strings are no more than 10​4​​. 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 S​1​​−S​2​​ 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的更多相关文章

  1. PAT 甲级 1050 String Subtraction (20 分) (简单送分,getline(cin,s)的使用)

    1050 String Subtraction (20 分)   Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be t ...

  2. PAT 甲级 1050 String Subtraction

    https://pintia.cn/problem-sets/994805342720868352/problems/994805429018673152 Given two strings S~1~ ...

  3. PAT Advanced 1050 String Subtraction (20 分)

    Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be the remaining string after taking ...

  4. PAT甲级——A1050 String Subtraction

    Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be the remaining string after taking ...

  5. 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 ...

  6. PAT练习--1050 String Subtraction (20 分)

    题⽬⼤意:给出两个字符串,在第⼀个字符串中删除第⼆个字符串中出现过的所有字符并输出. 这道题的思路:将哈希表里关于字符串s2的所有字符都置为true,再对s1的每个字符进行判断,若Hash[s1[i] ...

  7. PAT 解题报告 1050. String Subtraction (20)

    1050. String Subtraction (20) Given two strings S1 and S2, S = S1 - S2 is defined to be the remainin ...

  8. PAT 1050 String Subtraction

    1050 String Subtraction (20 分)   Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be t ...

  9. pat 1050 String Subtraction(20 分)

    1050 String Subtraction(20 分) Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be the ...

随机推荐

  1. js动态删除行错误

    Uncaught TypeError: Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'. js ...

  2. POJ 3087:Shuffle'm Up

    Shuffle'm Up Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7364   Accepted: 3408 Desc ...

  3. 吴裕雄--天生自然 JAVASCRIPT开发学习:HTML DOM 集合(Collection)

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  4. Django1.11创建

    Djiango 1.11.1 虚拟环境配置 创建虚拟环境 mkvirtualenv 虚拟环境名字 -p python3 安装django pip install django==1.11.11 卸载包 ...

  5. css伪元素::before与::after使用基础示例

    1.指定文本前后添加内容 <div class="box">test</div> .box::before{ content: 'before'; marg ...

  6. 17.3.10--关于C元的变量类型所占字节问题和类型转化

    在C语言并没有对于严格规定short,int  long所占字节,只是做了宽泛要求:short:至少连个字节 int建议为一个机器字长,32位环境下机器字长是4个字节,64位环境机器字长是8个字节 s ...

  7. JQuery 点击子控件事件,不会触发父控件的事件

     $('.order-delete').on('tap', function (e) {                  console.log('删除1');                  c ...

  8. 二、提高期(Upping the Ante)

    二.提高期(Upping the Ante) Upping the Ante?这可是第四阶段的词.没办法,Greg Thomson用这个词代表第二阶段,看着喜欢,继续沿用. 经过两三个月的“图象+声音 ...

  9. 1. Ruby基础知识

    1. Ruby执行选项 符号 作用 -c 检查代码正确性 -w 警告模式运行 -e 字面脚本 -l 行模式运行 单独 ruby -c Hello.rb 组合 ruby -le 'print " ...

  10. long型长整数字在前端页面显示异常及其解决方法

    文章目录 1.引子 2.解决问题 (1)初试EL表达式取long型数值 (2)再探EL表达式取字符串格式long型数值 (3)最后一试---给EL表达式加引号 3.总结 1.引子 在做项目中,发现了一 ...