求回答!!!

稍等,我写个示例代码

示例代码

以下是一个使用 ANSI 转义码和光标控制的简单 C++ 示例:

#include <iostream>
#include <cstdlib> // for system("clear")
//当然,万能头也很好用,但解答时用码风太丑了

using namespace std;

void clearScreen() {
    // 用于在 Unix 类系统中清屏,Windows 系统可使用 system("cls");
    system("clear");
}

void moveCursor(int x, int y) {
    cout << "\033[" << y << ";" << x << "H";
}

void setTextColor(int color) {
    cout << "\033[" << color << "m";
}

void resetTextColor() {
    cout << "\033[0m";
}

int main(void) 
{
    clearScreen();
    
    // 设置文本颜色为红色
    setTextColor(31);
    cout << "This is a test message in red color!" << endl;

    // 重置文本颜色
    resetTextColor();

    // 移动光标到 (10, 5)
    moveCursor(10, 5);
    cout << "Cursor moved to (10, 5)!" << endl;

    // 清除当前行
    cout << "\033[K"; // 清除当前行
    
    return 0;
}

啊?

啥AI

1 个赞

可能看差了

报下名字嘛,没准很好用

@张雨泽 我打了那么多,你把解决方案给 @2345安全卫士 了?

@2345安全卫士 给的好

屏幕截图 2024-08-25 153651

在不在

我在

1 个赞

没找你

心碎了呢,再吃饭

私聊? @linan04143

啊哈哈 @张雨泽 谢谢哈

1 个赞

回复啊!!!

回复啊!!! @linan04143

这年头找他聊天真不容易啊

你怎么换头像了?

1 个赞

这是蔡老师微信头像