https://pintia.cn/problem-sets/994805342720868352/problems/994805429018673152

Given two strings S~1~ and S~2~, S = S~1~ - S~2~ is defined to be the remaining string after taking all the characters in S~2~ from S~1~. Your task is simply to calculate S~1~ - S~2~ 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 S~1~ and S~2~, respectively. The string lengths of both strings are no more than 10^4^. 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 S~1~ - S~2~ in one line.

Sample Input:

They are students.
aeiou

Sample Output:

Thy r stdnts.

代码:
#include <bits/stdc++.h>
using namespace std; const int maxn = 1e5 + 10;
char s1[maxn], s2[maxn]; int main() {
cin.getline(s1, maxn);
cin.getline(s2, maxn);
int len1 = strlen(s1), len2 = strlen(s2);
for(int i = 0; i < len1; i ++) {
for(int j = 0; j < len2; j ++) {
if(s1[i] == s2[j])
s1[i] = '*';
}
} for(int i = 0; i < len1; i ++) {
if(s1[i] != '*')
printf("%c", s1[i]);
}
printf("\n");
return 0;
}

  

PAT 甲级 1050 String Subtraction的更多相关文章

  1. PAT 甲级 1050 String Subtraction (20 分) (简单送分,getline(cin,s)的使用)

    1050 String Subtraction (20 分)   Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be t ...

  2. PAT甲级——1050 String Subtraction

    1050 String Subtraction Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be the remain ...

  3. PAT Advanced 1050 String Subtraction (20 分)

    Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be the remaining string after taking ...

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

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

  6. PAT练习--1050 String Subtraction (20 分)

    题⽬⼤意:给出两个字符串,在第⼀个字符串中删除第⼆个字符串中出现过的所有字符并输出. 这道题的思路:将哈希表里关于字符串s2的所有字符都置为true,再对s1的每个字符进行判断,若Hash[s1[i] ...

  7. PAT 解题报告 1050. String Subtraction (20)

    1050. String Subtraction (20) Given two strings S1 and S2, S = S1 - S2 is defined to be the remainin ...

  8. PAT 1050 String Subtraction

    1050 String Subtraction (20 分)   Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be t ...

  9. pat 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 ...

随机推荐

  1. day11迭代器 and 闭包

    函数名的使⽤以及第一类对象 函数名是一个变量, 但它是一个特殊的变量, 与括号配合可以执行函数的变量. 函数名就是变量名, 函数名存储的是函数的内存地址 函数名可以赋值给其他变量 函数名可以当做容器类 ...

  2. 改脚本之dbscaner

    默认的DBscaner只是用了ipy模块支持一个段的解析,但是我想让他加载脚本进行检测 所以,直接看 def __init__(self, target, thread): self.target = ...

  3. 【Mac】解决「另一个活跃的 Homebrew 进程正在进行中」问题

    问题描述 在安装 tesseract 的语言包时,由于网络下载速度太慢,我按下 ctrl + z 退出了安装,当再次输入安装命令时,系统报错如下: 解决方法 使用以下命令删除 homebrew 进程锁 ...

  4. Go 跨域请求问题

    在使用go语言写测试服务的时候遇到了前端跨域请求问题,只需在go中加入 w.Header().Set("Access-Control-Allow-Origin", "*& ...

  5. 20155220 2016-2017-2 《java程序设计》第二周学习总结

    教材学习内容总结 3.1类型.变量与运算符 1)基本类型 byte 字节型 1 byte short 短整型 2 bytes int 整型 4 bytes long 长整型 8 bytes float ...

  6. WPF MVVM从入门到精通7:关闭窗口和打开新窗口

    原文:WPF MVVM从入门到精通7:关闭窗口和打开新窗口 WPF MVVM从入门到精通1:MVVM模式简介 WPF MVVM从入门到精通2:实现一个登录窗口 WPF MVVM从入门到精通3:数据绑定 ...

  7. 【NOIP2018pj】题解

    [NOIP2018pj]题解 \(T1\) 题面 洛谷 题解 好像并没有什么好说的... #include <iostream> #include <cstdio> #incl ...

  8. 润乾报表整合到Tomcat服务器的部署过程

    转载自:http://www.cnblogs.com/avivaye/archive/2012/11/16/2773681.html 使用第三方的报表设计器/服务器来快速的开发报表. 润乾服务器是使用 ...

  9. Intellif IDEA 自带数据库管理工具 DataBase 配置

    第一步: 第二步: 第三步: jdbc:oracle:thin:@192.168.19.39:1521:orcl

  10. 原生 js 简单实现 Promise

    写在思否,欢迎各位大佬给出建议: https://segmentfault.com/a/1190000018530433