TB椰程 TypeBuddy 打字搭子

2024-12 · 3级 · 打印数字

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

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

  • 2024-12
  • 字符串

正文

// GESP 2024-12 C++ 3级 编程题 2 · 打印数字
// 原题:https://oj.yecheng.tv/p/gs2412l3p2
// 官方原卷:https://gesp.ccf.org.cn/101/attach/1650388837072928.pdf
// 题意:小杨为数字 , , 和设计了一款表示形式,每个数字占用了的网格。
// 知识点:字符串、位运算
// 参考程序:CCF 原卷官方标程,PDF 抽取后已去行号;本地编译核验通过,供打字练习
// 原卷样例验证:样例验证 1/1 通过
//
#include <iostream>
#include <string>
using namespace std;
int main() {
    string n;
    cin >> n;
    for (int row = 0; row < 5; row++) {
        string line = "";
        for (char digit : n) {
            if (digit == '0') {
                if (row == 0 || row == 4) {
                    line += ".....";
                } else {
                    line += ".***.";
                }
            } else if (digit == '1') {
                line += "****.";
            } else if (digit == '2') {
                if (row == 0) {
                    line += ".....";
                } else if (row == 1) {
                    line += "****.";
                } else if (row == 2) {
                    line += ".....";
                } else if (row == 3) {
                    line += ".****";
                } else {
                    line += ".....";
                }
            } else if (digit == '3') {
                if (row == 0) {
                    line += ".....";
                } else if (row == 1) {
                    line += "****.";
                } else if (row == 2) {
                    line += ".....";
                } else if (row == 3) {
                    line += "****.";
                } else {
                    line += ".....";
                }
            }
        }
        cout << line << endl;
    }
    return 0;
}

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

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