1050 String Subtraction
题意:给出两个字符串s1和s2,在s1中删去s2中含有的字符。
思路:注意,因为读入的字符串可能有空格,因此用C++的getline(cin,str)。PAT系统迁移之后C语言中的gets()函数被禁用了。
代码:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string str1,str2;
getline(cin,str1);
getline(cin,str2);
]={false};//needDeleted[ch]为true表示字符ch应当删去
for(auto ch:str2) needDeleted[ch]=true;
for(auto ch:str1){
if(needDeleted[ch]) continue;//遇到需要删去的字符不输出
else cout<<ch;
}
;
}
1050 String Subtraction的更多相关文章
- PAT 解题报告 1050. String Subtraction (20)
1050. String Subtraction (20) Given two strings S1 and S2, S = S1 - S2 is defined to be the remainin ...
- PAT 1050 String Subtraction
1050 String Subtraction (20 分) Given two strings S1 and S2, S=S1−S2 is defined to be t ...
- 1050 String Subtraction (20 分)
1050 String Subtraction (20 分) Given two strings S1 and S2, S=S1−S2 is defined to be the ...
- pat 1050 String Subtraction(20 分)
1050 String Subtraction(20 分) Given two strings S1 and S2, S=S1−S2 is defined to be the ...
- PAT 甲级 1050 String Subtraction (20 分) (简单送分,getline(cin,s)的使用)
1050 String Subtraction (20 分) Given two strings S1 and S2, S=S1−S2 is defined to be t ...
- PAT甲级——1050 String Subtraction
1050 String Subtraction Given two strings S1 and S2, S=S1−S2 is defined to be the remain ...
- 1050. String Subtraction (20)
this problem is from PAT, which website is http://pat.zju.edu.cn/contests/pat-a-practise/1050. firs ...
- PAT (Advanced Level) 1050. String Subtraction (20)
简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...
- PAT甲题题解-1050. String Subtraction (20)-水题
#include <iostream> #include <cstdio> #include <string.h> #include <algorithm&g ...
- PAT 甲级 1050 String Subtraction
https://pintia.cn/problem-sets/994805342720868352/problems/994805429018673152 Given two strings S~1~ ...
随机推荐
- c++中的函数对象《未完成》
头文件: #pragma once #include<iostream> #include<vector> using namespace std; class Student ...
- 通过使用Netty实现RPC
目标:通过使用Netty框架实现RPC(远程过程调用协议),技术储备为以后实现分布式服务框架做技术储备.在这里实现自定义协议主要实现远程方法调用. 技术分析: 1.通过Java的反射技术我们可以获取对 ...
- python学习笔记(生成xml)
想着给框架加些功能 首先想到的是生成测试报告 这里就涉及到了生成什么格式的文件 我这边就准备生成 xml 格式的文件 自己先学习了整理了下 代码如下: #!/usr/bin/env python # ...
- Spring 在xml配置里配置事务
事先准备:配置数据源对象用<bean>实例化各个业务对象. 1.配置事务管理器. <bean id="transactionManager" class=&quo ...
- Struts06---通配符的使用
01.创建对应的login.jsp页面 <%@ page language="java" import="java.util.*" pageEncodin ...
- shell与正则表达式
作业一:整理正则表达式博客 已整理完.作业二:grep作业(正则表达式及字符处理) 目标文件/etc/passwd,使用grep命令或egrep 1.显示出所有含有root的行:[root@bogon ...
- C++轮子队-软件需求规格说明书
团队Github项目仓库 软件规格需求说明书 引言 编写目的 软件规格需求说明书书了“2048俄罗斯方块”1.0版本的软件功能性需求和非功能性需求. 文档约定 描述编写文档时所采用的标准或排版约定,包 ...
- react 项目及视频
项目 视频
- less 应用
链接 变量传入, 实现不同方向的三角形
- 使用Reaver破解开启了WPS功能的wifi密码(wpa/wpa2)
来自wikipeida: Wi-Fi保护设置(简称WPS,全称Wi-Fi Protected Setup)是一个无线网络安全标准,旨在让家庭用户使用无线网络时简化加密步骤.此标准由Wi-Fi联盟(Wi ...