1050. String Subtraction (20)

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.
题意

给定两个字符串,S1 和 S2,要求将 S2 中的字符从 S1 串中剔除。

分析

用 Hash 的方式标记需要剔除的字符。

#include <iostream>
#include <cstdio>
#include <string> using namespace std; int main()
{
int hs[] ={};
char cs[];
gets(cs);
string st = cs;
//getline(cin, st);
while () {
char c = getchar();
if (c == '\n') break;
hs[c] = ;
} for (int i=; i<st.size(); i++) {
if (hs[st[i]] == )
printf("%c", st[i]);
} return ;
}

PAT 解题报告 1050. String Subtraction (20)的更多相关文章

  1. PAT (Advanced Level) 1050. String Subtraction (20)

    简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...

  2. 【PAT甲级】1050 String Subtraction (20 分)

    题意: 输入两个串,长度小于10000,输出第一个串去掉第二个串含有的字符的余串. trick: ascii码为0的是NULL,减去'0','a','A',均会导致可能减成负数. AAAAAccept ...

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

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

  5. PAT甲题题解-1050. String Subtraction (20)-水题

    #include <iostream> #include <cstdio> #include <string.h> #include <algorithm&g ...

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

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

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

  8. 1050. String Subtraction (20)

    this problem  is from PAT, which website is http://pat.zju.edu.cn/contests/pat-a-practise/1050. firs ...

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

随机推荐

  1. Smarty 配置文件的读取

    http://www.cnblogs.com/gbyukg/archive/2012/06/12/2539067.html

  2. 如何删除docker images/containers

    docker images往往不知不觉就占满了硬盘空间,为了清理冗余的image,可采用以下方法: 1.进入root权限 sudo su 2.停止所有的container,这样才能够删除其中的imag ...

  3. pureftpd安装配置[总结]

    http://www.ttlsa.com/linux/how-to-install-pureftpd/ 看了这篇文章[几个小坑]总结如下: 1.最重要的一点,代码不要复制,有些符号肉眼看不出来. ./ ...

  4. faker image

    $faker->image http://placehold.it http://placekitten.com/g/200/300 带文字 https://placeholdit.imgix. ...

  5. 常见的Mule Esb下载地址

    http://www.myexception.cn/open-source/1832157.html

  6. To do

    小事{ android values public.xml 树.图的所有遍历方式和优劣 } 大事{ 通读android所有官网文档. android多dex多res开发框架. java AOT(and ...

  7. magento多语言中文语言包

    语言包key:http://connect20.magentocommerce.com/community/Mage_Locale_zh_CN

  8. Introduction to Project Management(I)

    Project management in the modern sense began in the early 1950s, although it has its roots further b ...

  9. Asp.net MVC 中超链接的三个方法及比较

    在Asp.net WebForm开发中,我们通过a标签进行跳转时,通常的写法是:<a href="index.aspx">首页</a>, 在Asp.net ...

  10. C# RichTextBox 滚动条 滚动到最后一行

    使用RichTextBox控件用于显示数据时,滚动条只停留在开头,而我希望能够一直更新,显示最后一行的内容.解决方法记录于此. 转载自以下链接: http://blog.csdn.net/xelone ...