pat 1084 Broken Keyboard(20 分)
1084 Broken Keyboard(20 分)
On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters corresponding to those keys will not appear on screen.
Now given a string that you are supposed to type, and the string that you actually type out, please list those keys which are for sure worn out.
Input Specification:
Each input file contains one test case. For each case, the 1st line contains the original string, and the 2nd line contains the typed-out string. Each string contains no more than 80 characters which are either English letters [A-Z] (case insensitive), digital numbers [0-9], or _ (representing the space). It is guaranteed that both strings are non-empty.
Output Specification:
For each test case, print in one line the keys that are worn out, in the order of being detected. The English letters must be capitalized. Each worn out key must be printed once only. It is guaranteed that there is at least one worn out key.
Sample Input:
7_This_is_a_test
_hs_s_a_es
Sample Output:
7TI
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <map>
#include <stack>
#include <vector>
#include <queue>
#include <set>
#define LL long long
using namespace std;
const int MAX = 2e3 + ; char s1[MAX], s2[MAX];
int A[MAX] = {}; int main()
{
// freopen("Date1.txt", "r", stdin);
scanf("%s%s", &s1, &s2);
int len1 = strlen(s1), len2 = strlen(s2); for (int i = ; i < len2; ++ i)
if (s2[i] >= 'A' && s2[i] <= 'Z')
A[s2[i]] = , A[s2[i] - 'A' + 'a'] = ;
else if (s2[i] >= 'a' && s2[i] <= 'z')
A[s2[i]] = , A[s2[i] - 'a' + 'A'] = ;
else
A[s2[i]] = ; for (int i = ; i < len1; ++ i)
{
if (A[s1[i]] == ) continue;
char a = s1[i];
if (a >= 'a' && a <= 'z')
{
A[a] = ;
a = char(a - 'a' + 'A');
A[a] = ;
}
else if (a >= 'A' && a <= 'Z')
A[a] = , A[a - 'A' + 'a'] = ;
else
A[a] = ;
printf("%c", a);
}
return ;
}
pat 1084 Broken Keyboard(20 分)的更多相关文章
- 【PAT甲级】1084 Broken Keyboard (20 分)
题意: 输入两行字符串,输出第一行有而第二行没有的字符(对大小写不敏感且全部以大写输出). AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #inclu ...
- PAT 1084 Broken Keyboard
1084 Broken Keyboard (20 分) On a broken keyboard, some of the keys are worn out. So when you type ...
- 1084. Broken Keyboard (20)【字符串操作】——PAT (Advanced Level) Practise
题目信息 1084. Broken Keyboard (20) 时间限制200 ms 内存限制65536 kB 代码长度限制16000 B On a broken keyboard, some of ...
- PAT 1084 Broken Keyboard[比较]
1084 Broken Keyboard (20 分) On a broken keyboard, some of the keys are worn out. So when you type so ...
- 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 ...
- 1084. Broken Keyboard (20)
On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters ...
- PAT (Advanced Level) 1084. Broken Keyboard (20)
简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...
- 1084. Broken Keyboard (20)-水题
#include <iostream> #include <cstdio> #include <string.h> #include <algorithm&g ...
- pat1084. Broken Keyboard (20)
1084. Broken Keyboard (20) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue On a ...
随机推荐
- 你必须知道的容器监控 (1) Docker自带子命令与Weave Scope
本篇已加入<.NET Core on K8S学习实践系列文章索引>,可以点击查看更多容器化技术相关系列文章.本篇会介绍几个目前比较常用且流行的容器监控工具,首先我们来看看Docker自带的 ...
- cinatra::http框架编译使用
cinatra 一个高效易用的c++ http框架 1.下载源码 https://github.com/qicosmos/cinatra 2. vs2017 编译boost库 [msvc-14.1] ...
- 彩虹战队waf测试工具(测试数据)
安全狗 D盾 云锁 360主机卫士 奇安信 绿盟 腾讯云 百度云 阿里云 小米斗鱼 启明星辰/天融信 深信服 华为 知道创宇 长亭 360天眼
- 5G:今天不谈技术,谈谈需求和应用
4G改变生活,5G改变社会.随着2019年5G手机的发布,5G时代已经拉开帷幕,无数嗅觉灵敏的投资人和创业者在研究5G行业的投资机会. 但是,市场研究侧重于技术细节与上游产业链设备投资居多,对于贴近消 ...
- ssd原理及代码实现详解
通过https://github.com/amdegroot/ssd.pytorch,结合论文https://arxiv.org/abs/1512.02325来理解ssd. ssd由三部分组成: ba ...
- 史上最轻松入门之Spring Batch - 轻量级批处理框架实践
从 MariaDB 一张表内读 10 万条记录,经处理后写到 MongoDB . Batch 任务模型 具体实现 1.新建 Spring Boot 应用,依赖如下: <!-- Web 应用 -- ...
- CheckBox多选
前台: <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> & ...
- Mysql数据库(十)MySQL性能优化
一.优化概述 为了提高MySQL数据库的性能,不要进行一系列的优化措施.如果MySQL数据库需要进行大量的查询操作,那么就需要对查询语句进行优化.对于耗费时间的查询语句进行优化,可以提高整体地查询速度 ...
- Java连接MySQL简单步骤及常见问题解析
这篇文章跟读者们介绍Java语言如何连接到MySQL数据库相关操作,及FAQ(Frequently Asked Questions)介绍. 选择工具和准备数据集 IDE:Eclipse 数据库:使用的 ...
- C++学习笔记2_函数.函数指针.函数模板
1. 内联函数void printAB(int a,int b){ cout<<(a)<<(b)<<endl;}int main(void){ for(int i= ...