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 ...
随机推荐
- CF543A Writing Code
题目描述 Programmers working on a large project have just received a task to write exactly m m m lines o ...
- Mysql分表的一个考虑
今天看到一篇博客,讲述的是Mysql的分表方案,内容比较简单,不过有个思路倒是挺好的,记录下,后续分表可以参考 作者主要是说到两种分表,一个是取模,另一个是范围分表 取模:比如用户ID%10,分10张 ...
- 让button的文字换行和左对齐
btn.titleLabel.numberOfLines = 0; btn.contentHorizontalAlignment = UIControlContentHorizontalAlign ...
- C#数据转换
C 货币 2.5.ToString("C") ¥2.50 D 十进制数 25.ToString("D5") 00025 E 科学型 25000.ToString ...
- [UWP]使用GetAlphaMask制作阴影
1. 前言 最近常常接触到GetAlphaMask,所以想写这篇文章介绍下GetAlphaMask怎么使用.其实GetAlphaMask的使用场景十分有限,Github上能搜到的内容都是用来配合Dro ...
- 【JS】深入理解JS原型和继承
前言 在学习JS中的原型,原型链,继承这些知识之前,我们先学习下基础知识:函数和对象的关系. 我们一直都知道,函数也是对象的一种,因为通过instanceof就可以判断出来.但是函数和对象的关系并不 ...
- JVM学习记录2--垃圾回收算法
首先要明确,垃圾回收管理jvm的堆内存,方法区是堆内存的一部分,所以也是. 而本地方法栈,虚拟机栈,程序计数器随着线程开始而产生,线程的结束而消亡,是不需要垃圾回收的. 1. 判断对象是否可以被回收 ...
- LNMP与LAMP的工作原理
LAMP的实现原理 LAMP=Linux+Apache+Mysql+PHP.#工作原理:浏览器向服务器发送http请求,服务器 (Apache) 接受请求,由于php作为Apache的组件模块也会一 ...
- 简要概括java技术体系
以前一直在学java程序设计语言,学完了就以为自己已经把java学得差不多了,直到最近在看一本书<深入理解java虚拟机>,才发现自己以前学的只不过是冰山一角.相信很多小伙伴跟我一样,在没 ...
- 关于php注释那些事
代码注释的作用 --- 为自己,也为别人. 永远不要过于相信自己的理解力!当你思路通畅,思如泉涌,进入编程境界,你可以很流畅的实现某个功能,但这种一泻千里的流畅可能只停留在了当时的状态.当你几个月, ...