A1050
输入两个字符串,将第一个字符串中包含的第二个字符串的字符去掉(包括空格),然后输出。
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的更多相关文章
- A1050. String Subtraction
Given two strings S1 and S2, S = S1 - S2 is defined to be the remaining string after taking all the ...
- A1050 String Subtraction (20 分)
一.技术总结 这个是使用了一个bool类型的数组来判断该字符是否应该被输出. 然后就是如果在str2中出现那么就判断为false,被消除不被输出. 遍历str1如果字符位true则输出该字符. 还有需 ...
- PAT甲级——A1050 String Subtraction
Given two strings S1 and S2, S=S1−S2 is defined to be the remaining string after taking ...
- 1050 String Subtraction (20 分)
1050 String Subtraction (20 分) Given two strings S1 and S2, S=S1−S2 is defined to be the ...
- PAT_A1050#String Subtraction
Source: PAT A1050 String Subtraction (20 分) Description: Given two strings S1 and S2, S=S1− ...
- PAT甲级题解分类byZlc
专题一 字符串处理 A1001 Format(20) #include<cstdio> int main () { ]; int a,b,sum; scanf ("%d %d& ...
随机推荐
- Windows 如何查看本地端口被进程占用的情况?
1.查看端口占用情况: 1.开始--运行--cmd 进入命令提示符. 2. 输入netstat -ano(或netstat -nao) ,即可看到所有进程(这里显示进程的PID)占用端口的情况. 3. ...
- Struts2学习-Ioc学习
网址:http://blog.csdn.net/qq_22654611/article/details/52606960可以在这个网址学学. 1.新建空项目,然后建立Java EE,在把Java EE ...
- January 15 2017 Week 3 Sunday
A good book is the best of friends, the same today and forever. 好书乃挚友,情谊永不渝. For a coder, that is no ...
- redis三节点sentinel部署
角色 ip port master 127.0.0.1 6379 slave-1 127.0.0.1 6380 slave-2 127. ...
- Redis配置文件(3)常见的配置修改
常见的配置: redis.conf 配置项说明如下: 1. Redis默认不是以守护进程的方式运行,可以通过该配置项修改,使用yes启用守护进程 daemonize no 2. 当Redis以 ...
- logback配置与使用(2)
转载:yaoh371 的logback.xml常用配置 <?xml version="1.0" encoding="UTF-8"?> <!-- ...
- js 模拟百度关键字搜索与跳转
测试效果: css样式: ul{ display:none; } html代码: <input type="text" id="text" /> & ...
- phpstudy 出现You don't have permission to access / on this server.
You don't have permission to access / on this server. 去掉vhost文件中的Options FollowSymLinks ExecCGI 第一次发 ...
- php开发微信图灵机器人
本着开源为原则,为这个世界更美好作出一份共享,我就给大家做个指路人,如果实用,记得给提供开源的朋友一些鼓励. 简单介绍一下实现思路,使用swoole扩展接管php运行,由于swoole只能在类UNIX ...
- iOS:动画(18-10-15更)
目录 1.UIView Animation 1-1.UIView Animation(基本使用) 1-2.UIView Animation(转场动画) 2.CATransaction(Layer版的U ...