题意:

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

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. Unable to guess the mime type as no guessers are available (Did you enable the php_fileinfo extension?)

    原因是没有开启php的php_fileinfo扩展,开启即可. 找到php.ini文件,搜索到php_fileinfo,去掉前面的分号,然后重启服务器apache.nginx下同理. extensio ...

  2. 最近手机价格全线暴跌真的只是因为5G要来了吗?

    等等党,是一群数量颇大的消费群体.他们的消费习性是绝不买刚上市的新品,而是一直等.等到他们认为产品的价格已经跌无可跌,或者性价比十足的时候再出手.不得不说,与早买早享受的尝鲜消费群体相比,等等党代表了 ...

  3. Illegal target for the requested operation

    org.tigris.subversion.javahl.ClientException: Illegal target for the requested operation svn: Commit ...

  4. Docker+JMeter单机版+File Browser

    基于JMeter5.1.1+File Browser2.1.0  JMeter发起压测  File Browser作为文件服务器 一.目录结构: Dockerfile文件: FROM ubuntu:1 ...

  5. 10day 系统的selinux服务程序优化

    selinux服务对root用户权限进行控制 很多企业中:selinux服务默认关闭 centos6==centos7 临时关闭: 检查确认: getenforce --- 确认selinux服务是否 ...

  6. LTE引理——解决数论竞赛题的利器

    LTE (Lifting The Exponent Lemma)引理是一个解指数型不定方程的强力工具.它在Olympiad folklore非常知名,虽然它的起源已经无从查找了.它和Hensel’s ...

  7. wget 显示网页内容到控制台

    wget -q -O -  http://www.microsoft.com

  8. Js选择器总结

    一.原生JS选择器 JS选择器常用的有getElementById().getElementsByName().getElementsByTagName().getElementsByClassNam ...

  9. macos 杀掉端口 命令行

    sudo lsof -i:3000 kill 11111 1111就是pid下面的数字

  10. IDEA格式化代码快捷键失灵原因

    网易云音乐快捷键与IDEA快捷键冲突了!!!!!!!坑爹