TB椰程 TypeBuddy 打字搭子

2023-12 · 4级 · 小杨的字典

GESP 标程 · 考级真题 · 代码 · cpp · 难度 5/5 · 共 1091 字

CCF 原卷官方标程 · 字符串、STL、位运算 · 本地编译通过

  • 2023-12
  • 字符串

正文

// GESP 2023-12 C++ 4级 编程题 1 · 小杨的字典
// 原题:https://oj.yecheng.tv/p/gs2312l4p1
// 官方原卷:https://gesp.ccf.org.cn/101/attach/1601236293910560.pdf
// 题意:在遥远的星球,有两个国家 A 国和 B 国,他们使用着不同的语言:A 语言和 B 语言。
// 知识点:字符串、STL、位运算
// 参考程序:CCF 原卷官方标程,PDF 抽取后已去行号;本地编译核验通过,供打字练习
// 原卷样例验证:样例验证 3/3 通过
//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
using namespace std;
map<string, string> dict;
int main() {
    int N;
    cin >> N;
    while(N --) {
        string word1, word2;
        cin >> word1 >> word2;
        dict[word1] = word2;
    }
    string content, word = "";
    cin >> content, content += "\n";
    int m = content.length();
    for(int i = 0; i < m; i ++) {
        if (content[i] >= 'a' && content[i] <= 'z')
            word += content[i];
        else {
            if (word != "") {
                if (dict.count(word))
                    cout << dict[word];
                else cout << "UNK";
                word = "";
            }
            cout << content[i];
        }
    }
    return 0;
}

GESP 标程 · 考级真题的其它内容

打字首页 · 英语学习中心 · 词库画廊 · 编程打字 · 指法入门 · 天梯榜 · 数据分析 · 班级课堂 · 关于我们
椰程 TypeBuddy 打字搭子 —— 键盘指法练习 · 单词记忆 · 班级课堂 · 在线 PK