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. Rails中生成并在ActionMailer附件中发送csv、excel、pdf、zip文件

    1.修改Gemfile # PDF generator gem 'prawn' gem 'prawn-table' # Excel generator gem 'rubyXL' #Zip genera ...

  2. ruby rspec+jenkins+ci_report持续集成生成junit测试报告

    1.加载ci_report gem install ci_reporter_rspec 2.给测试工程编写rakefile require 'ci/reporter/rake/rspec' requi ...

  3. DDoS 攻击与防御:从原理到实践

    本文来自 网易云社区 . 可怕的 DDoS 出于打击报复.敲诈勒索.政治需要等各种原因,加上攻击成本越来越低.效果特别明显等趋势,DDoS 攻击已经演变成全球性的网络安全威胁. 危害 根据卡巴斯基 2 ...

  4. Go黑帽子

    使用go语言来实现python黑帽子和绝技的代码 1.unix密码破解器 package main import( "bufio" "flag" "i ...

  5. golang基础--method方法

    Go没有类似python语言中类class的概念,但依旧有method 类型方法定义格式如下 func (a mytype) method_name(x type)(y type){ return y ...

  6. 20155320 《Java程序设计》实验三 敏捷开发与XP实践

    20155320 <Java程序设计>实验三 敏捷开发与XP实践 实验内容 XP基础 XP核心实践 相关工具 (一)研究一下Code菜单 具体内容: 在IDEA中使用工具(Code-> ...

  7. 【BZOJ3197】[SDOI2013]刺客信条

    [BZOJ3197][SDOI2013]刺客信条 题面 bzoj 洛谷 题解 关于树的同构,有一个非常好的性质: 把树的重心抠出来,那么会出现两种情况: 1.有一个重心,那么我们直接把这个重心作为树的 ...

  8. 1150: [CTSC2007]数据备份Backup

    1150: [CTSC2007]数据备份Backup https://lydsy.com/JudgeOnline/problem.php?id=1150 分析: 堆+贪心. 每次选最小的并一定是最优的 ...

  9. Python socket网络模块

    一.基于TCP协议的socket通信 以打电话为理解方式进行TCP的通信. Server端代码: import socket phone = socket.socket(socket.AF_INET, ...

  10. PHPStrom 里修改Emmet对php的自动扩展

    PHPStrom 7.1.3 Emmet 想必大家都比较清楚了.Emmet有个特点,对于匹配不到的符号,仍然会自动扩展为标签的形式,比如我输入aaaa,然后按tab,会自动扩展为<aaaa> ...