题意:

输入两行字符串,输出第一行有而第二行没有的字符(对大小写不敏感且全部以大写输出)。

AAAAAccepted code:

 #define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
string s1,s2;
bool vis[];
vector<char>ans;
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>s1>>s2;
int n=s1.size();
int p=;
int pos=;
for(int i=;i<n;++i){
if(s1[i]==s2[p])
++p;
else if(!vis[s1[i]-'']){
if(s1[i]>='a'&&s1[i]<='z')
ans.push_back(s1[i]-'a'+'A');
else
ans.push_back(s1[i]);
vis[s1[i]-'']=;
if(s1[i]>='a'&&s1[i]<='z')
vis[s1[i]-'a'+'A'-'']=;
else if(s1[i]>='A'&&s1[i]<='Z')
vis[s1[i]-'A'+'a'-'']=;
}
if(p==s2.size()){
pos=i+;
break;
}
}
for(int i=pos;i<n;++i)
if(!vis[s1[i]-'']){
ans.push_back(s1[i]);
vis[s1[i]-'']=;
if(s1[i]>='a'&&s1[i]<='z')
vis[s1[i]-'a'+'A'-'']=;
else if(s1[i]>='A'&&s1[i]<='Z')
vis[s1[i]-'A'+'a'-'']=;
}
for(auto it:ans)
cout<<it;
return ;
}

【PAT甲级】1084 Broken Keyboard (20 分)的更多相关文章

  1. PAT Advanced 1084 Broken Keyboard (20) [Hash散列]

    题目 On a broken keyboard, some of the keys are worn out. So when you type some sentences, the charact ...

  2. 1084. Broken Keyboard (20)【字符串操作】——PAT (Advanced Level) Practise

    题目信息 1084. Broken Keyboard (20) 时间限制200 ms 内存限制65536 kB 代码长度限制16000 B On a broken keyboard, some of ...

  3. PAT 甲级 1035 Password (20 分)

    1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for th ...

  4. 1084. Broken Keyboard (20)

    On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters ...

  5. PAT 甲级 1073 Scientific Notation (20 分) (根据科学计数法写出数)

    1073 Scientific Notation (20 分)   Scientific notation is the way that scientists easily handle very ...

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

  7. PAT 甲级 1046 Shortest Distance (20 分)(前缀和,想了一会儿)

    1046 Shortest Distance (20 分)   The task is really simple: given N exits on a highway which forms a ...

  8. PAT 甲级 1042 Shuffling Machine (20 分)(简单题)

    1042 Shuffling Machine (20 分)   Shuffling is a procedure used to randomize a deck of playing cards. ...

  9. PAT 甲级 1041 Be Unique (20 分)(简单,一遍过)

    1041 Be Unique (20 分)   Being unique is so important to people on Mars that even their lottery is de ...

随机推荐

  1. AD转换器的主要技术指标

    1)分辩率(Resolution) 指数字量变化一个最小量时模拟信号的变化量,定义为满刻度与2n的比值.分辩率又称精度,通常以数字信号的位数来表示.     2) 转换速率(Conversion Ra ...

  2. java-判断年份是不是闰年

    if ((year%4==0)&&(year%100!=0)||(year%400==0)) {//是闰年 leapYear = true; }

  3. 在多租户(容器)数据库中如何创建PDB:方法5 DBCA远程克隆PDB

    基于版本:19c (12.2.0.3) AskScuti 创建方法:DBCA静默远程克隆PDB.将 CDB1 中的 PDB1 克隆为 CDB2 中的 ERP2 对应路径:Creating a PDB ...

  4. WebRTC笔记(一)

    来源<WebRTC权威指南> 1 WebRTC特点 对等连接(Peer Connection):浏览器与浏览器(万维网上的任意两个通信终端)之间的连接(P2P) 信令服务器:在浏览器和对等 ...

  5. APP开发工具如何选?

    随着技术的发展,在当前开发一款APP已经非常的简单和快速.特别是近些年,利用HTML5技术将APP的开发门槛进一步降低.各种开发工具和框架层出不穷,令人眼花缭乱.这么多的工具摆在眼前应该如何进行选择呢 ...

  6. Tomcat 端口配置,及原理详解

    1 tomcat 文件配置详细说明 tomcat服务器需配置三个端口才能启动,安装时默认启用了这三个端口,当要运行多个tomcat服务时需要修改这三个端口,不能相同.端口配置路径为tomcat\ co ...

  7. python之路之html

    def index(request): print request.POST print request.GET print request.FILES for item in request.FIL ...

  8. C++-POJ1021-2D-Nim[hash]

    哈希,对于每个点哈希一次 哈希的方式:该点到联通分量边界(上下左右)的距离和 然后分别对两个图的n个点按hash值排序,判断是否相等即可 #include <set> #include & ...

  9. 格式化输出_python

    一.直接使用 +a='chen'b='xiao'c='zan'print(a+b+c) 二.利用占位符 %%s:占位符:%d:整数:%x:十六进制:%f:浮点数(默认6位小数)特别注意浮点数: 指定长 ...

  10. 题解【UVA10054】The Necklace

    题目描述 输入格式 输出格式 题意简述 有一种由彩色珠子连接而成的项链.每个珠子的两半由不同颜色组成.如图所示,相邻两个珠子在接触的地方颜色相同.现在有一些零碎的珠子,需要确认它们是否可以复原成完整的 ...