zoukankan      html  css  js  c++  java
  • 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
     1 #include <iostream>
     2 #include <algorithm>
     3 #include <cstdio>
     4 #include <cstring>
     5 #include <map>
     6 #include <stack>
     7 #include <vector>
     8 #include <queue>
     9 #include <set>
    10 #define LL long long
    11 using namespace std;
    12 const int MAX = 2e3 + 10;
    13 
    14 char s1[MAX], s2[MAX];
    15 int A[MAX] = {0};
    16 
    17 int main()
    18 {
    19 //    freopen("Date1.txt", "r", stdin);
    20     scanf("%s%s", &s1, &s2);
    21     int len1 = strlen(s1), len2 = strlen(s2);
    22 
    23     for (int i = 0; i < len2; ++ i)
    24         if (s2[i] >= 'A' && s2[i] <= 'Z')
    25             A[s2[i]] = 1, A[s2[i] - 'A' + 'a'] = 1;
    26         else if (s2[i] >= 'a' && s2[i] <= 'z')
    27             A[s2[i]] = 1, A[s2[i] - 'a' + 'A'] = 1;
    28         else
    29             A[s2[i]] = 1;
    30 
    31     for (int i = 0; i < len1; ++ i)
    32     {
    33         if (A[s1[i]] == 1) continue;
    34         char a = s1[i];
    35         if (a >= 'a' && a <= 'z')
    36         {
    37             A[a] = 1;
    38             a = char(a - 'a' + 'A');
    39             A[a] = 1;
    40         }
    41         else if (a >= 'A' && a <= 'Z')
    42             A[a] = 1, A[a - 'A' + 'a'] = 1;
    43         else
    44             A[a] = 1;
    45         printf("%c", a);
    46     }
    47     return 0;
    48 }
  • 相关阅读:
    团队冲刺第二阶段4
    团队冲刺第二阶段3
    Kibana客户端安装
    Elasticsearch安装IK分词器
    ElasticSearch 安装笔记
    smtp邮件发送
    5.28 vue2的diff算法
    4.24observer中并不会出现类似obj.data.name读取时,obj的data与data的name都出现被读取的现象。(改正错误!)
    4.1 原来cookie由浏览器管理!(服务端返回cookie后,浏览器保存cookie,再次发起http请求时会包含一个cookie的头部)
    4.1 HTTP请求中的Form Data与Request Payload的区别
  • 原文地址:https://www.cnblogs.com/GetcharZp/p/9591530.html
Copyright © 2011-2022 走看看