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 ...
随机推荐
- Zabbix监控系统部署:配置详解
1. 全局配置 ListenPort ,监听端口 ,取值范围为1024-32767,默认端口10051 SourceIP,外发连接源地址 LogType,日志类型:单独日志文件,系统文件,控制台输出 ...
- Week 3 有求必应
[引] 必应词典已经伴我很久了,但那并不意味着我天天都用它查来查去,它总是静静地蹲在我E盘的一角. 从前的它特别任性,总喜欢开机自己冒出头来看我.后来我嫌它每天都播报新闻,于是就把它关进了冷宫.直到不 ...
- 网络:LVS负载均衡原理
LB集群的架构和原理很简单,就是当用户的请求过来时,会直接分发到Director Server上,然后它把用户的请求根据设置好的调度算法,智能均衡地分发到后端真正服务器(real server)上.为 ...
- JAVA链表中迭代器的实现
注:本文代码出自<java数据结构和算法>一书. PS:本文中类的名字定义存在问题,Link9应改为Link.LinkList9应该为LinkList.由于在同包下存在该名称,所以在后面接 ...
- JAVA面对对象(五)——接口
接口由全局常量和公共的抽象方法组成,接口的定义格式: interface 接口名称{ 全局常量; 抽象方法; } 接口中的抽象方法必须定义为public访问权限,在接口中如果不写也默认是public访 ...
- HTML的input类型为hidden导致无法reset改字段的value问题
问题关键:根据HTML规范,hidden是非ui类元素,不接受用户处理.所以form的 reset并不影响它. http://stackoverflow.com/questions/6367793/w ...
- JQuery 操作 radio 被坑一例
.removeAttr('checked'); .prop('checked',false); .prop('checked',true); 与 .attr("checked",t ...
- Docker(十六)-Docker的daemon.json的作用
docker安装后默认没有daemon.json这个配置文件,需要进行手动创建.配置文件的默认路径:/etc/docker/daemon.json 一般情况,配置文件 daemon.json中配置的项 ...
- 通过几个例子看sed的模式空间与保持空间
SED之所以能以行为单位的编辑或修改文本,其原因在于它使用了两个空间:一个是活动的“模式空间(pattern space)”,另一个是起辅助作用的“暂存缓冲区(holdingspace)这2个空间的使 ...
- hive数据查询
Fetch task 丢弃了mapreduce的作业的繁重任务,查询方便简单 1.第一种方式 2.linux命令行 3.地3中