PAT (Advanced Level) Practise 1084 Broken Keyboard (20)
2017-07-04 14:08
435 查看
1084. Broken Keyboard (20)
时间限制200 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue
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 <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <functional>
using namespace std;
#define LL long long
const int INF = 0x3f3f3f3f;
char a[100], b[100];
int visit[300];
int main()
{
while (~scanf("%s%s", a, b))
{
memset(visit, 0, sizeof visit);
int l = 0, r = 0;
while (a[l])
{
if (a[l] == b[r]) l++, r++;
else
{
int k;
if (a[l] >= 'a'&&a[l] <= 'z') k=a[l] - 32;
else k=a[l];
if (!visit[k]) printf("%c", k);
visit[k] = 1;
l++;
}
}
printf("\n");
}
return 0;
}
相关文章推荐
- PAT (Advanced Level) Practise 1084 Broken Keyboard (20)
- Pat(Advanced Level)Practice--1084(Broken Keyboard)
- PAT (Advanced Level) Practise - 1096. Consecutive Factors (20)
- PAT (Advanced Level) Practise 1015 Reversible Primes (20)
- PAT (Advanced Level) Practise 1058 A+B in Hogwarts (20)
- PAT (Advanced Level) Practise 1092 To Buy or Not to Buy (20)
- PAT (Advanced Level) Practise 1019 General Palindromic Number (20)
- PAT-PAT (Advanced Level) Practise 1008. Elevator (20) (简单模拟)【一星级】
- 1088. Rational Arithmetic (20)——PAT (Advanced Level) Practise
- 1104. Sum of Number Segments (20)【数学题】——PAT (Advanced Level) Practise
- PAT-PAT (Advanced Level) Practise A+B and C (64bit) (20) 【二星级】
- 1023. Have Fun with Numbers (20)【字符串操作】——PAT (Advanced Level) Practise
- 1046. Shortest Distance (20)【贪心】——PAT (Advanced Level) Practise
- 1023. Have Fun with Numbers (20) @ PAT (Advanced Level) Practise
- PAT (Advanced Level) Practise 1011 World Cup Betting (20)
- PAT (Advanced Level) Practise - 1005. Spell It Right (20)
- PAT (Advanced Level) Practise 1061 Dating (20)
- PAT (Advanced Level) Practise 1046 Shortest Distance (20)
- PAT (Advanced Level) Practise 1042 Shuffling Machine (20)
- PAT (Advanced Level) Practise 1041 Be Unique (20)