输入两个字符串,将第一个字符串中包含的第二个字符串的字符去掉(包括空格),然后输出。

gets()不能用了,我混搭了string和length(),不用纠结长度还是很好的。

第二个字符串所在HashTable数组对应位置如果不等于0,则清零。输出非零位置对应ch1的字符。

书上的代码更简洁一些,但是我尽力了orz。

 #include<cstdio>
#include<iostream>
#include<string.h>
using namespace std;
string ch1,ch2;
int hashTable[];
int main(){
getline(cin,ch1);
getline(cin,ch2);
int len1=ch1.length();
int len2=ch2.length();
for(int i=;i<len1;i++){
hashTable[ch1[i]]++;
} for(int i=;i<len2;i++){
hashTable[ch2[i]]=;
} for(int i=;i<len1;i++){
if(hashTable[ch1[i]]!=){
printf("%c",ch1[i]);
}
}
return ;
}

A1050的更多相关文章

  1. A1050. String Subtraction

    Given two strings S1 and S2, S = S1 - S2 is defined to be the remaining string after taking all the ...

  2. A1050 String Subtraction (20 分)

    一.技术总结 这个是使用了一个bool类型的数组来判断该字符是否应该被输出. 然后就是如果在str2中出现那么就判断为false,被消除不被输出. 遍历str1如果字符位true则输出该字符. 还有需 ...

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

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

  5. PAT_A1050#String Subtraction

    Source: PAT A1050 String Subtraction (20 分) Description: Given two strings S​1​​ and S​2​​, S=S​1​​− ...

  6. PAT甲级题解分类byZlc

    专题一  字符串处理 A1001 Format(20) #include<cstdio> int main () { ]; int a,b,sum; scanf ("%d %d& ...

随机推荐

  1. Infragist ics Ult imate 2015 Vol.1 - Product Keys

    Ultimate ProductKeys 2015 Vol.1: 9122-1900164-4504144 9122-9300855-3994197 9122-7600717-4579130 9122 ...

  2. 【Leetcode】【Medium】Binary Tree Right Side View

    Given a binary tree, imagine yourself standing on the right side of it, return the values of the nod ...

  3. LINUX系统文件类型分类

    使用LINUX过程中,时常会对文件进行操作.但是linux中文件究竟有哪些分类呢?今天让我们大家来总结一下吧! 概述: linux文件可以分为五种类型,分别为:普通文件.目录.字符设备或块设备.套接口 ...

  4. 正则表达式 (python)

    正则表达式 在正则表达式中,如果直接给出字符,就是精确匹配. 用\d可以匹配一个数字,\w可以匹配一个字母或数字,所以: '00\d'可以匹配'007',但无法匹配'00A': '\d\d\d'可以匹 ...

  5. 如何退出virtualbox scale mode

    进入scale mode之后,可能会退不出来 HOST Key + C. 默认是 右Ctrl + C

  6. June 23rd 2017 Week 25th Friday

    Life doesn't get easier, you just get stronger. 生活从未变得轻松,是你在一点一点变得坚强. So in the same way we can get ...

  7. 深入理解JNI 邓平凡

    深入理解JNI 邓凡平 1)使用的时候 :加载libmedia_jni.so 并接着调用JNI_Onload->register_android_media_MediaScanner动态注册JN ...

  8. Oracle 数据库视图与基表的关系

    本文转载自:http://www.linuxidc.com/Linux/2015-03/115165.htm 一:首先解释什么是视图: 视图其实就是一条查询sql语句,用于显示一个或多个表或其他视图中 ...

  9. 牛客网多校训练第一场 E - Removal(线性DP + 重复处理)

    链接: https://www.nowcoder.com/acm/contest/139/E 题意: 给出一个n(1≤n≤1e5)个整数(范围是1至10)的序列,求从中移除m(1≤m≤min(n-1, ...

  10. python代码是解释型语言,为什么还有编译过程?

    Python 代码在运行前,会先编译(翻译)成中间代码,每个 .py 文件将被换转成 .pyc 文件,.pyc 就是一种字节码文件,它是与平台无关的中间代码,不管你放在 Windows 还是 Linu ...