PAT 甲级 1050. String Subtraction (20)
来源:互联网 发布:乌鲁木齐网络架构师 编辑:程序博客网 时间:2024/05/29 11:04
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 104. 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.aeiouSample Output:
Thy r stdnts.
#include <iostream>using namespace std;int main(){ string s1,s2; getline(cin,s1); getline(cin,s2); bool hash[256]={false}; //hash[256]={true}并不是全部初始化成为true,这种想法是错的! for(int i=0;i<s2.length();i++){ hash[s2[i]]=true; } for(int i=0;i<s1.length();i++){ if(hash[s1[i]]==false) cout<<s1[i]; } return 0;}
阅读全文
0 0
- 【PAT甲级】1050. String Subtraction (20)
- 1050. String Subtraction (20) PAT甲级
- PAT(甲级)1050. String Subtraction (20)
- PAT甲级练习1050. String Subtraction (20)
- PAT甲级1050. String Subtraction (20)
- 1050. String Subtraction (20)-PAT甲级
- PAT 甲级 1050. String Subtraction (20)
- PAT甲级 1050. String Subtraction (20)
- 1050. String Subtraction (20)-PAT甲级真题(哈希)
- 1050. String Subtraction (20)-PAT
- PAT 1050. String Subtraction (20)
- PAT 1050. String Subtraction (20)
- pat 1050. String Subtraction (20)
- PAT 1050. String Subtraction (20)
- PAT 1050. String Subtraction (20)
- PAT 1050. String Subtraction
- PAT 1050. String Subtraction
- 【PAT】1050. String Subtraction
- 表单提交编码问题 utf-8 你到底哪里去了
- MySQL数据库操作总结
- 深入理解mybatis原理-Mybatis数据源与连接池
- 1002 数塔取数问题 (DP
- PAT 甲级 1049. Counting Ones (30)
- PAT 甲级 1050. String Subtraction (20)
- hrbust 软微学院 2016 ACM选拔重现 标程
- Java入门之使用记事本写Java程序及简单命令符
- Java定时调度任务详解之Timer篇
- 557. Reverse Words in a String III
- caffe2 教程入门(python版)
- NIO与IO的区别
- 2054 数据结构实验之链表九:双向链表
- JAVA基础