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 ...
随机推荐
- 个人java框架 技术分析
1.框架选型 spring-boot https://github.com/JeffLi1993/springboot-learning-example https://mp.weixin.qq.co ...
- PHP 设置调试工具XDebug PHPStorm IDE
先下载PHP扩展Xdebug https://xdebug.org, 可以复制自己的phpinfo粘贴到https://xdebug.org/wizard.php中, 会生成需要下载的版本, php. ...
- GlusterFS分布式存储系统中更换故障Brick的操作记录
前面已经介绍了GlusterFS分布式存储集群环境部署记录,现在模拟下更换故障Brick的操作: 1)GlusterFS集群系统一共有4个节点,集群信息如下: 分别在各个节点上配置hosts.同步好系 ...
- centos7下安装php+memcached简单记录
1)centos7下安装php 需要再添加一个yum源来安装php-fpm,可以使用webtatic(这个yum源对国内网络来说恐怕有些慢,当然你也可以选择其它的yum源) [root@nextclo ...
- Python-习题-11
1,内容回顾列表:增 append insert extend 删 remove pop clear del 改 li[索引] = '被修改的内容' li[切片]:'被修改的内容' 查 for循环 r ...
- 牛客多校第二场A run(基础DP)
链接:https://www.nowcoder.com/acm/contest/140/A来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 131072K,其他语言2621 ...
- cf946d 怎样逃最多的课dp
来源:codeforces D. Timetable Ivan is a student at Berland ...
- navicat有数据额结构同步
这个功能可能检查两个库的表结构异同,进行表结构构同步,可以生成同步语句. 比如在测试环境表中新增了字段,可以通过这个工具进行表结构同步.
- 数据驱动测试之—— Excel+TestNG
对于利用Webdriver做自动化的童鞋,对于如何将元素或者输入数据如何和编码分离都应该不会太陌生,本着一边学习一边分享的心态,大概总结了一下关于利用CSV.XML以及Excel来存放数据,然后在结合 ...
- Oracle 导入导出报错的简单处理
这边出现报错: 简单查了下资料发现: https://blog.csdn.net/lichkui/article/details/5489708 在imp 的命令后面 增加buffer 即可 比如 i ...