PAT甲级——A1050 String Subtraction
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 1. 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.
#include <iostream>
#include <string>
using namespace std;
int main()
{
int ascll[] = { };
string str = "", S1, S2;
getline(cin, S1);
getline(cin, S2);//注意S2也可能有空格
cin >> S2;
for (int i = ; i < S2.length(); ++i)
ascll[S2[i]] = -;
for (int i = ; i < S1.length(); ++i)
if (ascll[S1[i]] == )
cout << S1[i];
return ;
}
PAT甲级——A1050 String Subtraction的更多相关文章
- 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 ...
- PAT 甲级 1050 String Subtraction
https://pintia.cn/problem-sets/994805342720868352/problems/994805429018673152 Given two strings S~1~ ...
- 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 Advanced 1050 String Subtraction (20 分)
Given two strings S1 and S2, S=S1−S2 is defined to be the remaining string after taking ...
- 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 ...
- PAT练习--1050 String Subtraction (20 分)
题⽬⼤意:给出两个字符串,在第⼀个字符串中删除第⼆个字符串中出现过的所有字符并输出. 这道题的思路:将哈希表里关于字符串s2的所有字符都置为true,再对s1的每个字符进行判断,若Hash[s1[i] ...
- PAT_A1050#String Subtraction
Source: PAT A1050 String Subtraction (20 分) Description: Given two strings S1 and S2, S=S1− ...
随机推荐
- Android问题集锦An error occurred while automatically activating bundle com.android.ide.eclipse.adt .
这是Eclipse的问题,重启之后问题依旧. 在坛子里找到这个办法,果然好用. 命令行到eclipse路径运行:eclipse.exe -clean
- HDU-6375-度度熊学队列-双端队列deque/list
度度熊正在学习双端队列,他对其翻转和合并产生了很大的兴趣. 初始时有 NN 个空的双端队列(编号为 11 到 NN ),你要支持度度熊的 QQ 次操作. ①11 uu ww valval 在编号为 u ...
- springcloud系列13 config的客户端使用
config客户端的使用: 也是首先要引入依赖: <dependency> <groupId>org.springframework.cloud</groupId> ...
- vue qs插件的使用
参考:https://blog.csdn.net/weixin_43851769/article/details/86505164 qs 是一个增加了一些安全性的查询字符串解析和序列化字符串的库. 步 ...
- virtualbox导入winXP系统OVA文件重启
1,开启虚拟机 2,按f8进入安全模式,然后修改注册表: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Processor HKEY_LOC ...
- MapReduce工作流程
- Lua 协程和线程区别
协程就是协程,不是线程. CPU执行单位是线程,不是什么协程. 协程,是同步执行,不是并行,只是切了一个上下文了,为你保存原来的上下文而已. 切到第二个协程时,原来的协程处于挂起状态. 这个特指lua ...
- php curl的隐藏BUG
<?php $a = array( 'a' => 2, 'b' => 3, ); $curl = curl_init(); $b = $a; curl_setopt_array($c ...
- 修改cmd命令默认路径
未修改之前: 修改方法: 1.win+r打开运行对话框,输入 regedit 打开注册表编辑器 2.在注册表中找到:HKEY_CURRENT_USER\Software\Microsoft\Comma ...
- LintCode_1 单例模式
从今天开始我的LintCode之旅,由于C/C++好久没有使用了,语法生疏不说,低级错误频繁出现,因此在做题之后,还会有部分时间复习语法项目. ---------------------------- ...