旧键盘 (20)

旧键盘上坏了几个键,于是在敲一段文字的时候,对应的字符就不会出现。现在给出应该输入的一段文字、以及实际被输入的文字,请你列出
肯定坏掉的那些键。
输入描述:
输入在2行中分别给出应该输入的文字、以及实际被输入的文字。每段文字是不超过80个字符的串,由字母A-Z(包括大、小写)、数字0-9、

以及下划线“_”(代表空格)组成。题目保证2个字符串均非空。

输出描述:
按照发现顺序,在一行中输出坏掉的键。其中英文字母只输出大写,每个坏键只输出一次。题目保证至少有1个坏键。

输入例子:
7_This_is_a_test

_hs_s_a_es

输出例子:
7TI

#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

int main(void)
{
    int count[64] = {};

    string put_in;
    string put_out;

    cin >> put_in >> put_out;

    int len1 = put_in.length();
    int len2 = put_out.length();

    for (int i = 0; i < len2; i++)
    {
        if (put_out[i] <= '9'&&put_out[i] >= '0')
            count[put_out[i] - '0']=1;
        else if (put_out[i] <= 'Z'&&put_out[i] >= 'A')
            count[put_out[i] - 'A' + 10]=1;
        else if (put_out[i] <= 'z'&&put_out[i] >= 'a')
            count[put_out[i] - 'a' + 36]=1;
        else
            count[63]++;
    }

    for (int i = 0; i < len1; i++)
    {
        if (put_in[i] <= '9'&&put_in[i] >= '0')
        {
            if (0 == count[put_in[i] - '0'])
                printf("%c", put_in[i]), count[put_in[i] - '0']=2;
        }
        else if (put_in[i] <= 'Z'&&put_in[i] >= 'A')
        {
            if(0==count[put_in[i] - 'A' + 10])
                printf("%c", put_in[i]), count[put_in[i] - 'A' + 10] = 2, count[put_in[i] - 'A' + 36] = 2;
        }
        else if (put_in[i] <= 'z'&&put_in[i] >= 'a')
        {
            if (0 == count[put_in[i] - 'a' + 36])
                printf("%c", put_in[i] - 'a' + 'A'), count[put_in[i] - 'a' + 36] = 2, count[put_in[i] - 'a' + 10] = 2;
        }
        else
        if (0 == count[63])
            printf("%c", put_in[i]), count[63]=2;
    }

    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值