A1084. Broken Keyboard
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<cstdio>
#include<iostream>
using namespace std;
int trans(char c){
if(c >= 'a' && c <= 'z')
return c - 'a' + ;
else if(c >= 'A' && c <= 'Z')
return c - 'A' + ;
else if(c >= '' && c <= '')
return c - '';
else return ;
}
int main(){
char a[], b[];
int hashTab[] = {,};
scanf("%s %s", a, b);
for(int i = ; b[i] != '\0'; i++){
hashTab[trans(b[i])]= ;
}
for(int i = ; a[i] != '\0'; i++){
if(hashTab[trans(a[i])] == ){
hashTab[trans(a[i])] = ;
if(a[i] <= 'z' && a[i] >= 'a')
printf("%c", a[i] - 'a' + 'A');
else printf("%c", a[i]);
}
}
cin >> a;
return ;
}
总结:
1、由于本题不区分大小写,所以将大小写字母映射为10-35, _映射为36, 0-9映射为0-9即可。如果区分大小写,则可以直接将ASCII的个数128映射为数组下标。
A1084. Broken Keyboard的更多相关文章
- PAT甲级——A1084 Broken Keyboard
On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters ...
- PAT_A1084#Broken Keyboard
Source: PAT A1084 Broken Keyboard (20 分) Description: On a broken keyboard, some of the keys are wor ...
- 1084 Broken Keyboard (20 分)
1084 Broken Keyboard (20 分) On a broken keyboard, some of the keys are worn out. So when you type so ...
- UVa 11998 Broken Keyboard (数组模拟链表问题)
题目链接: 传送门 Broken Keyboard #include<bits/stdc++.h> using namespace std; char str[100010]; int m ...
- UVa 11988 Broken Keyboard(链表->数组实现)
/*数组形式描述链表:链表不一定要用指针. 题目链接:UVa 11988 Broken Keyboard 题目大意: 小明没有开屏幕输入一个字符串,电脑键盘出现了问题会不定时的录入 home end ...
- 1084. Broken Keyboard (20)
On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters ...
- B - Broken Keyboard (a.k.a. Beiju Text)
Problem B Broken Keyboard (a.k.a. Beiju Text) You're typing a long text with a broken keyboard. Well ...
- uva - Broken Keyboard (a.k.a. Beiju Text)(链表)
11988 - Broken Keyboard (a.k.a. Beiju Text) You’re typing a long text with a broken keyboard. Well i ...
- PAT1084:Broken Keyboard
1084. Broken Keyboard (20) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue On a ...
随机推荐
- Spring+SpringMVC+MyBatis+easyUI整合进阶篇(八)线上Mysql数据库崩溃事故的原因和处理
前文提要 承接前文<一次线上Mysql数据库崩溃事故的记录>,在文章中讲到了一次线上数据库崩溃的事件记录,建议两篇文章结合在一起看,不至于摸不着头脑. 由于时间原因,其中只讲了当时的一些经 ...
- Docker 小记 — Docker Engine
前言 用了 Docker 方才觉得生产环境终于有了他该有的样子,就像集装箱普及之后大型货轮的价值才逐渐体现出来,Docker 详细说明可查阅"官方文档".本篇为 Docker En ...
- Mvc_前后端绑定数据json集合
ViewBag.SysModuleList =new List<SysModule>(){.....}; var data = @Html.Raw(Json.Encode(ViewBag ...
- 11.13 Daily Scrum
今天在实现餐厅列表时,原来使用的百度地图poi搜索接口无法返回餐厅的具体信息. 经过一番周折,找到了一个返回餐厅url的接口.我们调整了一下实现,在点击餐厅列表的某一项点击直接跳到和该餐厅信息有关的网 ...
- Filter(转载)
web.xml中元素执行的顺序listener->filter->struts拦截器->servlet. 1.过滤器的概念 Java中的Filter 并不是一个标准的Servlet ...
- Dynamic Routing Based On Redis
Dynamic Routing Based On Redis Ngnix技术研究系列2-基于Redis实现动态路由 上篇博文我们写了个引子: Ngnix技术研究系列1-通过应用场景看Nginx的反 ...
- How To Install MySQL on Ubuntu 16.04
https://help.ubuntu.com/lts/serverguide/mysql.html http://www.cnblogs.com/wuhou/archive/2008/09/28/1 ...
- Java的Vector源码阅读
* The {@code Vector} class implements a growable array of * objects. Like an array, it contains comp ...
- WebPage设计专业术语
header footer master content placeholder breadcrumb 面包屑(breadcrumb)源于一个童话,在网站中就是一行层级属性链接组成的线性链接标示(我的 ...
- Mind Manager X 10 registry backup key under windows XP
Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Mindjet\MindManager\10] [HKEY_CURRE ...