首页 > 代码库 > PAT 1084 Broken Keyboard

PAT 1084 Broken Keyboard

#include <cstdio>#include <cstdlib>#include <vector>using namespace std;char linea[82];char lineb[82];bool tbl[256];char cap(char ch) {     if (ch >= a && ch <= z) {        ch -= a - A;     }     return ch;}int main() {    scanf("%s", linea);    scanf("%s", lineb);    vector<char> broken;    char cha, chb;    int ia = 0, ib = 0;    while (linea[ia]!= \0 && lineb[ib] != \0) {          cha = cap(linea[ia]);          chb = cap(lineb[ib]);          if (cha == chb) {              ia++, ib++;                        } else {              if (!tbl[cha]) {                 broken.push_back(cha);                 tbl[cha] = true;              }              ia++;          }    }    while (linea[ia] != \0) {        cha = cap(linea[ia]);        if (!tbl[cha]) {           broken.push_back(cha);           tbl[cha] = true;        }        ia++;    }    int len = broken.size();    for (int i=0; i<len; i++){        printf("%c", broken[i]);        }    system("pause");        return 0;    }

链表Merge类题目

PAT 1084 Broken Keyboard