Pat B-1029. Old keyboard (-native)

Source: Internet
Author: User

The old keyboard has broken several keys, so when you knock a text, the corresponding characters will not appear. Now give me a piece of text that should be entered, and the text that is actually entered, please list the keys that are definitely broken.

Input format:

Enter the text to be entered in line 2, and the text that is actually entered. Each text is a string of no more than 80 characters, consisting of the letter A-Z (including large, lowercase), number 0-9, and underscore "_" (for spaces). The problem is that 2 strings are not empty.

Output format:

Output the broken key in one line in the Order of discovery. The English letters only output uppercase, each bad key output only once. The title is guaranteed to have at least 1 bad keys.

Input Sample:
7_this_is_a_test
_hs_s_a_es
Output Sample:
7TI

Train of thought: compare the input string with the actual string, note that the comparison is not case-sensitive, found that the actual string does not have the character in the input string Fu Paocun in the str array, while saving to traverse the STR array to find whether it has been saved and not saved before saving.

#include <iostream> #include <cstdio> #include <cstring> using namespace std;
    int main () {char str1[85];
    Char str2[85];
    Char str[85]={-1};
    Gets (STR1);
    Gets (STR2);
    int k=0;
    BOOL Find1=false;
    BOOL Find2=false;
            for (int i = 0;i < strlen (str1); i++) {//double for loop, compare input with actual for (int j = 0; J < strlen (str2); + +) {                 if (ToUpper (Str1[i]) ==toupper (str2[j)) find1=true;
                    Find} if (!find1) {for (int m=0;m<strlen (str); m++) {//If not found, see if it has been saved
                    if (ToUpper (Str1[i]) ==toupper (Str[m])) {find2=true;
            } if (!find2) {//Not saved is saved Str[k++]=toupper (Str1[i]);
        }} Find1=false;
    Find2=false;
    for (int i=0;i<k;i++) {cout<<str[i];
return 0; }

Topic Link:

https://www.patest.cn/contests/pat-b-practise/1029

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.