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

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. impala安装笔记(Ubuntu)

    1.Override 1.With Impala, you can query data, whether stored in HDFS or Apache HBase – including SEL ...

  2. XISE菜刀V13.0 官网版 XISE菜刀VIP破解版 XISE官网

    诠释: 1. 破解VIP登陆限制 2.去后门 (自查) 下载地址 :https://pan.baidu.com/s/1eR2rUOM 查毒地址:http://a.virscan.org/a3983f3 ...

  3. MyEclipse中关于JRE System Library、Web App Libraries的疑惑

    简要说明一下:其实,这三个都是jar包的存放集合. 1.JRE System Library主要存放J2SE的标准jar,一般不需要调整. 2.Referenced Libraries是存放第三方的j ...

  4. hiredis

    hiredis是redis开源库对外发布的客户端API包. 当redis-server配置启动后,可以通过hiredis操作redis资源. 主要分为: strings.hash.lists.sets ...

  5. SAP Cloud for Customer里Sales Order和Sales Quote的建模方式

    SAP Cloud for Customer的Sales工作中心里有Sales Quote和Sales Order两个视图,一个用于销售报价单,另一个用于销售订单. 流程上是先有报价单 ,报价单是一份 ...

  6. 关于Jsp页面的jstl标签的级联属性的异常。

    使用SpringMVC框架时,当我做表单回显时. 情景描述.Employee 类有一个Department类的属性.这两个类存在多对一关联关系. 下面是Employee类的属性的定义. public ...

  7. Git bash 终止git log 命令

    Git bash中 可以通过键入: q ,结束该命令.

  8. 3spring:生命周期,属性赋值,自动装配

    有不懂的可以参考之前的文章! https://www.cnblogs.com/Mrchengs/p/10109053.html 1.Bean的生命周期     创建---初始化---销毁   容器管理 ...

  9. 443M衣架遥控arduino代码备档

    ] = {,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,}; ] = {,,,,,,,,,,,,,,,,,,,,,,, ...

  10. SPOJ SUBXOR

    SPOJ SUBXOR 题意 给定一个由正整数构成的数组, 求 异或和小于k 的子序列的个数. 题解 假设答案区间为 [L, R], XOR[L, R] 等价于 XOR[1, L - 1] ^ XOR ...