首页 > 代码库 > 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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。