1050 String Subtraction (20 分)
1050 String Subtraction (20 分)
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.
aeiou
Sample Output:
Thy r stdnts.
具体代码:
getline一套
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;
bool hashtable[120]={false};int main(){string S1;string S2;getline(cin,S1);getline(cin,S2);//因为字符串中有空格所以不用scanfint len1=S1.length();int len2=S2.length();for(int i=0;i<len2;i++){hashtable[S2[i]-'0']=true;}for(int i=0;i<len1;i++){if(hashtable[S1[i]-'0']==false)cout<<S1[i];}return 0;}
1050 String Subtraction (20 分)相关推荐
- PAT甲级 -- 1050 String Subtraction (20 分)
Given two strings S1 and S2, S=S1−S2 is defined to be the remaining string after taking ...
- 【PAT甲级 删除字符串中的指定字符】1050 String Subtraction (20 分) C++
题目 删除字符串中的另一个字符串包含的所有字符. 可以通过判断两个字符串是否为空,来稍微优化一下运行速度 题解C++ #include<iostream> #include<stri ...
- 1050 String Subtraction (20 分)_10行代码AC
立志用最少的代码做最高效的表达 PAT甲级最优题解-->传送门 Given two strings S1 and S2, S=S1−S2 is defined to be ...
- C++ PAT甲级 1050 String Subtraction (20分)
Given two strings S1 and S2, S=S1−S2is defined to be the remaining string aftertaking all the cha ...
- 【PAT (Advanced Level) Practice】1050 String Subtraction (20 分)
C/C++中整型数组的下标类型不一定为整型,C C++语言下数组性质与散列有些类似,即散列中的键值对:下标即为关键码,关键码通过散列函数映射得到元素即为值 下标可以为整型,也可以为字符型,简单案例如下 ...
- PAT甲题题解-1050. String Subtraction (20)-水题
#include <iostream> #include <cstdio> #include <string.h> #include <algorithm&g ...
- PAT:1050. String Subtraction (20) AC
#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; bool ...
- PAT甲级1050 String Subtraction
题目 1050 String Subtraction (20 分) Given two strings S1 and S2 , S=S1−S2 is defined to be the remai ...
- 1050 String Subtraction
1050 String Subtraction (20 分) Given two strings S1 and S2, S=S1−S2 is defined to be the ...
- PAT甲级1050 String Subtraction:[C++题解]字符串作差
文章目录 题目分析 朴素算法 hash表优化 题目链接 题目分析 遇到的问题:如何删除下标i的值,我的意思是i后面的需要前移吗?还是有好的解决方法. 笔者想到的是打上标记! string读入一整行的方 ...
最新文章
- 这个赛车AI不再只图一时爽,学会了考虑长远策略
- 并发模型与IO模型梳理
- Java锁详解之ReentrantLock
- MongoDB 小试牛刀
- php 提取登录QQ,php QQ登录
- 李飞飞演讲实录 | 云原生数据库2.0:一站式全链路数据管理与服务
- Linux嵌入式 -- Bootloader , Uboot
- Qt笔记-windows下拷贝文件夹中所有文件
- 深度残差收缩网络:(四)注意力机制下的阈值设置
- 三星电视开机显示服务器异常,三星液晶电视常见故障及维修方法
- session的简介
- 春节档影片的成本各是多少?
- win10打开蓝牙_WIN10蓝牙不能使用,开启蓝牙后不能识别到其它设备怎么办?
- 轻松构建并发送ICMP数据包
- 入行这么久? 真正理解了缓存吗
- Maven系列(四):Maven内置属性,pom属性
- java开源saas项目
- win7中如何获取IE8的缓存视频文件
- 移动操作系统的优劣及下一代移动系统展望
- 【题解】POJ 3069 Saruman's Army(贪心)
热门文章
- curl 同时发送多个请求
- Nginx负载均衡 后端服务器怎么共享Session 问题
- linux之程序包管理器(rpm)
- 毕业5年决定你的一生_4
- 支持x64的开发工具
- sever2008 ad用户和计算机不见,windows-server-2008 – 当我使用Powershell将用户添加到安全组时,它们不会显示在AD中...
- 递归算法的基本理解以及基本算法,多行注释详解,适合编程小白,刚接触递归的编程新手
- php字符串操作整理,PHP学习之整理字符串
- ant 使用java 运行类_用ANT构建java可执行程序
- SQL order by的用法