神奇的小代码
2026-08-07 15:38:15
发布于:浙江
#define WIN32_LEAN_AND_MEAN
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <windows.h>
#include <chrono>
#include <thread>
#include <map>
#include <stdexcept>
#include <bits/stdc++.h>
using namespace std;
// === 全局变量:记录当前控制台颜色 ===
WORD g_CurrentColor = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; // 默认为白色(7)
// 颜色输出封装
void colorPrint(const std::string& text, WORD color = -1) {
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
// 如果传入了特定颜色,就临时切换;否则使用全局当前颜色
if (color != -1) {
SetConsoleTextAttribute(hConsole, color);
} else {
SetConsoleTextAttribute(hConsole, g_CurrentColor);
}
std::cout << text;
// 恢复标准属性(防止影响后续非 colorPrint 的输出,虽然这里主要都用这个)
// 注意:这里不恢复成7,而是保持 g_CurrentColor,方便连续输出
}
// 专门用于设置全局背景/文字颜色的函数
void setGlobalColor(WORD color) {
g_CurrentColor = color;
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, g_CurrentColor);
}
std::map<char, std::vector<std::string>> asciiArt = {
{'A', {" A ", " A A ", "AAAAA", "A A", "A A"}},
{'B', {"BBBB ", "B B", "BBBB ", "B B", "BBBB "}},
{'C', {" CCCC", "C ", "C ", "C ", " CCCC"}},
{'D', {"DDD ", "D D", "D D", "D D", "DDD "}},
{'E', {"EEEEE", "E ", "EEEE ", "E ", "EEEEE"}},
{'F', {"FFFFF", "F ", "FFFF ", "F ", "F "}},
{'G', {" GGG ", "G ", "G GG", "G G", " GGG "}},
{'H', {"H H", "H H", "HHHHH", "H H", "H H"}},
{'I', {"IIIII", " I ", " I ", " I ", "IIIII"}},
{'J', {"JJJJJ", " J ", " J ", "J J ", " JJ "}},
{'K', {"K K", "K K ", "KKK ", "K K ", "K K"}},
{'L', {"L ", "L ", "L ", "L ", "LLLLL"}},
{'M', {"M M", "MM MM", "M M M", "M M", "M M"}},
{'N', {"N N", "NN N", "N N N", "N NN", "N N"}},
{'O', {" OOO ", "O O", "O O", "O O", " OOO "}},
{'P', {"PPPP ", "P P", "PPPP ", "P ", "P "}},
{'Q', {" QQQ ", "Q Q", "Q Q Q", "Q Q ", " QQ Q"}},
{'R', {"RRRR ", "R R", "RRRR ", "R R ", "R R"}},
{'S', {" SSS ", "S ", " SSS ", " S", "SSS "}},
{'T', {"TTTTT", " I ", " I ", " I ", " I "}},
{'U', {"U U", "U U", "U U", "U U", " UUU "}},
{'V', {"V V", "V V", "V V", " V V ", " V "}},
{'W', {"W W", "W W", "W W W", "WW WW", "W W"}},
{'X', {"X X", " X X ", " X ", " X X ", "X X"}},
{'Y', {"Y Y", " Y Y ", " Y ", " Y ", " Y "}},
{'Z', {"ZZZZZ", " Z ", " Z ", " Z ", "ZZZZZ"}},
{' ', {" ", " ", " ", " ", " "}},
{'!', {" ! ", " ! ", " ! ", " ", " ! "}}
};
double applyOp(double a, double b, char op) {
switch (op) {
case '+': return a + b;
case '-': return a - b;
case '*': return a * b;
case '/':
if (b == 0) throw std::runtime_error("错误:除数不能为0");
return a / b;
default: return 0;
}
}
// === 辅助函数:判断运算符优先级 ===
int precedence(char op) {
if (op == '+' || op == '-') return 1;
if (op == '*' || op == '/') return 2;
return 0;
}
// === 核心函数:双栈解析表达式 ===
double calculateExpression(const string& s) {
stack<double> values; // 操作数栈
stack<char> ops; // 运算符栈
for (int i = 0; i < s.length(); i++) {
// 1. 跳过空格
if (s[i] == ' ') continue;
// 2. 如果是数字,读取完整数值(支持小数)
if (isdigit(s[i]) || s[i] == '.') {
double val = 0;
double decimalPlace = 0.1;
bool isDecimal = false;
while (i < s.length() && (isdigit(s[i]) || s[i] == '.')) {
if (s[i] == '.') {
isDecimal = true;
} else {
if (isDecimal) {
val += (s[i] - '0') * decimalPlace;
decimalPlace *= 0.1;
} else {
val = val * 10 + (s[i] - '0');
}
}
i++;
}
values.push(val);
i--; // 回退一位,因为for循环会自动+1
}
// 3. 如果是左括号,入栈
else if (s[i] == '(') {
ops.push(s[i]);
}
// 4. 如果是右括号,结算括号内的所有运算
else if (s[i] == ')') {
while (!ops.empty() && ops.top() != '(') {
double val2 = values.top(); values.pop();
double val1 = values.top(); values.pop();
char op = ops.top(); ops.pop();
values.push(applyOp(val1, val2, op));
}
if (!ops.empty()) ops.pop(); // 弹出 '('
}
// 5. 如果是运算符 (+ - * /)
else if (s[i] == '+' || s[i] == '-' || s[i] == '*' || s[i] == '/') {
// 当栈顶运算符优先级 >= 当前运算符时,先计算栈顶的
while (!ops.empty() && ops.top() != '(' &&
precedence(ops.top()) >= precedence(s[i])) {
double val2 = values.top(); values.pop();
double val1 = values.top(); values.pop();
char op = ops.top(); ops.pop();
values.push(applyOp(val1, val2, op));
}
ops.push(s[i]);
}
}
// 6. 处理剩余的运算符
while (!ops.empty()) {
if (ops.top() == '(') throw std::runtime_error("错误:括号不匹配"); // ? 加上 std::
double val2 = values.top(); values.pop();
double val1 = values.top(); values.pop();
char op = ops.top(); ops.pop();
values.push(applyOp(val1, val2, op));
}
if (values.empty()) throw runtime_error("错误:表达式为空");
return values.top();
}
void printArt(const std::string& text) {
// 假设你的 asciiArt map 中,每个字母的 vector 都有 5 行高度
int height = 5;
// 外层循环:控制行数 (从第0行到第4行)
for (int i = 0; i < height; ++i) {
// 内层循环:遍历用户输入的每一个字符
for (char c : text) {
// 转大写以匹配 Map 中的键 (A-Z)
char upperC = toupper(c);
// 查找字典里有没有这个字
if (asciiArt.find(upperC) != asciiArt.end()) {
// 获取该字母的图案数据
const std::vector<std::string>& rows = asciiArt[upperC];
// 打印该字母的第 i 行
// 注意:要确保 i 没有越界
if (i < rows.size()) {
std::cout << rows[i] << " "; // 字母之间加个空格
}
} else {
// 如果字典里没有这个字(比如中文或特殊符号),打印空格占位
std::cout << " ";
}
}
std::cout << std::endl; // 每一行打印完后,必须换行!
}
}
// 伪AI核心
void fakeAI() {
std::string input;
// 初始显示提示语
colorPrint("\n[AI] 请输入指令 (输入 'end' 结束AI对话): \n");
while (true) {
// 确保输入时的颜色也是当前的设定色
setGlobalColor(g_CurrentColor);
std::getline(std::cin, input);
if (input == "end") break;
// 1. 模拟思考
int thinkTime = 300 + (rand() % 500);
colorPrint("[AI] 正在分析...", FOREGROUND_GREEN | FOREGROUND_BLUE);
std::this_thread::sleep_for(std::chrono::milliseconds(thinkTime));
std::cout << "\r[AI] 思考完毕! \n";
std::vector<std::string> replies;
bool handled = false;
// === 功能模块 ===
// 功能1:报时
if (input.find("时间") != std::string::npos || input.find("几点") != std::string::npos) {
auto now = std::chrono::system_clock::now();
std::time_t now_time = std::chrono::system_clock::to_time_t(now);
char buffer[80];
std::strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", std::localtime(&now_time));
replies = {std::string("现在是:") + buffer};
handled = true;
}
// 功能2:打开软件
else if (input.find("打开") != std::string::npos && input.find("网站") == std::string::npos && input.find("文件") == std::string::npos) {
if (input.find("记事本") != std::string::npos) { system("start notepad"); replies = {"记事本已启动。"}; }
else if (input.find("计算器") != std::string::npos) { system("start calc"); replies = {"计算器已启动。"}; }
else if (input.find("画图") != std::string::npos) { system("start mspaint"); replies = {"画图工具已启动。"}; }
else { replies = {"我不知道你想打开什么软件。"}; }
handled = true;
}
// 功能3:打开网站
else if (input.find("网站") != std::string::npos || input.find("访问") != std::string::npos) {
std::string url = "";
if (input.find("baidu") != std::string::npos || input.find("百度") != std::string::npos) url = "www.baidu.com";
else if (input.find("bilibili") != std::string::npos || input.find("B站") != std::string::npos) url = "www.bilibili.com";
else if (input.find("github") != std::string::npos) url = "www.github.com";
else if (input.find("acgo") != std::string::npos) url = "www.acgo.cn";
else if (input.find("画图") != std::string::npos) url = "www.excalidraw.com";
else {
// 尝试提取 URL (简单处理)
size_t pos = input.find("http");
if(pos != std::string::npos) url = input.substr(pos);
else replies = {"请输入完整的网址,例如 https://www.baidu.com"};
}
if (!url.empty()) {
system(("start " + url).c_str());
replies = {"正在为你打开 " + url + " ..."};
}
handled = true;
}
// 功能4:随机数
else if (input.find("随机") != std::string::npos || input.find("抽奖") != std::string::npos) {
int num = rand() % 100 + 1;
replies = {"你的幸运数字是:" + std::to_string(num)};
handled = true;
}
// 功能5:换颜色 (核心修复部分)
else if (input.find("颜色") != std::string::npos || input.find("换") != std::string::npos) {
WORD colors[] = {
FOREGROUND_RED | FOREGROUND_INTENSITY, // 亮红
FOREGROUND_GREEN | FOREGROUND_INTENSITY, // 亮绿
FOREGROUND_BLUE | FOREGROUND_INTENSITY, // 亮蓝
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY, // 亮黄
FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY, // 亮青
FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY // 亮紫
};
WORD randomColor = colors[rand() % 6];
// 【关键】设置全局颜色变量
setGlobalColor(randomColor);
colorPrint("[AI] 颜色已切换!\n", FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); // 正确:白色
handled = true;
}
// 功能6:即时编译运行 C++ 代码
else if (input.find("编译") != std::string::npos || input.find("运行代码") != std::string::npos) {
// 恢复默认颜色以便阅读代码报错
setGlobalColor(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
colorPrint("[AI] 进入代码编译模式,请粘贴代码,完成后输入 'run' 并回车:\n", FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
std::ofstream outFile("temp_code.cpp");
std::string codeLine;
while (std::getline(std::cin, codeLine)) {
if (codeLine == "run") break;
outFile << codeLine << "\n";
}
outFile.close();
colorPrint("[AI] 正在编译...\n", FOREGROUND_GREEN);
int compileResult = system("g++ temp_code.cpp -o temp_run.exe -std=c++11 2>&1"); // 2>&1 捕获错误信息
if (compileResult == 0) {
colorPrint("[AI] 编译成功!运行结果如下:\n", FOREGROUND_GREEN);
system("temp_run.exe");
replies = {"子程序运行结束。"};
} else {
replies = {"编译失败!请检查代码语法。"};
}
handled = true;
}
else if (input.find("计算") != std::string::npos) {
// 1. 从用户指令中提取出算式部分
// 例如,从 "计算 1+1" 中提取 "1+1"
std::string expression = input.substr(input.find("计算") + 2);
// 2. 调用我们之前写好的双栈计算器函数
try {
double result = calculateExpression(expression);
// 3. 将结果转换成字符串并回复
replies = {"计算结果是:" + std::to_string(result)};
} catch (const std::exception& e) {
// 4. 捕获并显示计算错误(如除零、括号不匹配)
replies = {e.what()};
}
handled = true;
}
// 新增功能:ASCII艺术字
else if (input.find("艺术字") != std::string::npos || input.find("大字") != std::string::npos) {
std::string content = input;
size_t pos = content.find("艺术字");
if(pos != std::string::npos) content.erase(pos, 3);
pos = content.find("大字");
if(pos != std::string::npos) content.erase(pos, 2);
content.erase(0, content.find_first_not_of(" "));
if(!content.empty()) {
colorPrint("[AI] 正在生成艺术字...\n", FOREGROUND_GREEN);
printArt(content);
handled = true;
}
}
// 基础聊天
else {
if (input.find("你好") != std::string::npos || input.find("在吗") != std::string::npos) {
replies = {"你好,人类。", "我在,系统运行正常。"};
} else if (input.find("名字") != std::string::npos) {
replies = {"我是控制台伪AI,代号 V8.1。"};
} else if (input.find("笨") != std::string::npos || input.find("傻") != std::string::npos||input.find("**") != std::string::npos) {
replies = {"我的智商取决于你的代码质量。", "请勿对AI进行人身攻击。"};
} else {
replies = {"这是一个有趣的问题,但我现在不想回答。", "404 Not Found: 智商模块未响应。"};
}
}
// 打字机效果输出
if (!replies.empty()) {
std::string reply = replies[rand() % replies.size()];
// 确保回复也是当前设定的颜色
setGlobalColor(g_CurrentColor);
std::cout << "[AI] ";
for (char c : reply) {
std::cout << c;
std::this_thread::sleep_for(std::chrono::milliseconds(30 + (rand() % 30)));
}
std::cout << "\n";
}
// 重新显示提示符,并强制应用当前颜色
setGlobalColor(g_CurrentColor);
colorPrint("[AI] 请输入指令 (输入 'end' 结束AI对话): \n");
}
}
void gameGuessNumber() {
system("cls");
colorPrint("=== 猜数字挑战 ===\n", FOREGROUND_GREEN | FOREGROUND_INTENSITY);
std::cout << "我想了一个 1 到 100 之间的数字,你有 7 次机会猜中它!\n\n";
srand(time(0));
int target = rand() % 100 + 1;
int guess, attempts = 0;
while (attempts < 7) {
std::cout << "请输入你的猜测 (剩余 " << 7 - attempts << " 次): ";
if (!(std::cin >> guess)) {
std::cin.clear();
std::cin.ignore(10000, '\n');
colorPrint("请输入有效的数字!\n", FOREGROUND_RED);
continue;
}
attempts++;
if (guess == target) {
std::string msg = "\n恭喜你!猜对了!答案就是 " + std::to_string(target) + "\n";
colorPrint(msg, FOREGROUND_GREEN | FOREGROUND_INTENSITY);
break;
} else if (guess < target) {
colorPrint("太小了!再试一次。\n", FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
} else {
colorPrint("太大了!再试一次。\n", FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
}
}
if (attempts >= 7 && guess != target) {
std::string msg = "\n很遗憾,机会用完了。正确答案是: " + std::to_string(target) + "\n";
colorPrint(msg, FOREGROUND_RED);
}
system("pause");
}
void gameTicTacToe() {
system("cls");
char board[9] = {'1','2','3','4','5','6','7','8','9'};
char currentPlayer = 'X';
bool gameOver = false;
auto drawBoard = [&]() {
system("cls");
colorPrint("=== 井字棋 (输入1-9落子) ===\n\n", FOREGROUND_GREEN | FOREGROUND_INTENSITY);
for(int i=0; i<9; i+=3) {
for(int j=0; j<3; j++) {
WORD c = (board[i+j] == 'X') ? FOREGROUND_RED | FOREGROUND_INTENSITY :
(board[i+j] == 'O') ? FOREGROUND_BLUE | FOREGROUND_INTENSITY : 7;
colorPrint(std::string(1, board[i+j]) + " ", c);
if(j < 2) std::cout << "| ";
}
std::cout << "\n";
if(i < 6) std::cout << "---------\n";
}
std::cout << "\n";
};
auto checkWin = [&]() -> char {
int wins[8][3] = {{0,1,2},{3,4,5},{6,7,8},{0,3,6},{1,4,7},{2,5,8},{0,4,8},{2,4,6}};
for(auto& w : wins) {
if(board[w[0]] == board[w[1]] && board[w[1]] == board[w[2]])
return board[w[0]];
}
return ' ';
};
while(!gameOver) {
drawBoard();
std::cout << "玩家 " << currentPlayer << " 请落子 (1-9): ";
int pos;
std::cin >> pos;
if(pos < 1 || pos > 9 || board[pos-1] == 'X' || board[pos-1] == 'O') {
colorPrint("无效位置,请重试!\n", FOREGROUND_RED);
system("pause");
continue;
}
board[pos-1] = currentPlayer;
char winner = checkWin();
if(winner != ' ') {
drawBoard();
std::string msg = "玩家 " + std::string(1, winner) + " 获胜!\n";
colorPrint(msg, FOREGROUND_GREEN | FOREGROUND_INTENSITY);
gameOver = true;
} else {
bool full = true;
for(char c : board) if(c != 'X' && c != 'O') full = false;
if(full) {
drawBoard();
colorPrint("平局!\n", FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
gameOver = true;
} else {
currentPlayer = (currentPlayer == 'X') ? 'O' : 'X';
}
}
}
system("pause");
}
void gameReaction() {
system("cls");
colorPrint("=== 反应力测试 ===\n", FOREGROUND_GREEN | FOREGROUND_INTENSITY);
std::cout << "当屏幕出现 [点击!] 时,请立即按下回车键!\n";
std::cout << "按回车开始...\n";
std::cin.ignore(); // 等待第一次回车
srand(time(0));
int waitTime = 2000 + rand() % 3000; // 随机等待 2-5 秒
std::cout << "准备...\n";
Sleep(waitTime);
auto start = std::chrono::high_resolution_clock::now();
colorPrint("[点击!]\n", FOREGROUND_RED | FOREGROUND_INTENSITY);
std::cin.ignore(); // 等待用户按下回车
auto end = std::chrono::high_resolution_clock::now();
double duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
std::string msg = "你的反应时间是: " + std::to_string((int)duration) + " ms\n";
colorPrint(msg, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
if(duration < 200) colorPrint("神级反应!\n", FOREGROUND_GREEN | FOREGROUND_INTENSITY);
else if(duration < 300) colorPrint("非常快!\n", FOREGROUND_GREEN);
else if(duration < 500) colorPrint("普通人水平。\n", FOREGROUND_RED | FOREGROUND_GREEN);
else colorPrint("是不是睡着了?\n", FOREGROUND_RED);
system("pause");
}
void gameGomoku() {
system("cls");
const int SIZE = 15;
char board[SIZE][SIZE] = {0};
char currentPlayer = 'X';
bool gameOver = false;
auto drawBoard = [&]() {
system("cls");
colorPrint("=== 五子棋 (输入行号1-15和列号A-O) ===\n\n", FOREGROUND_GREEN | FOREGROUND_INTENSITY);
// 列标题
std::cout << " ";
for(int j = 0; j < SIZE; j++) {
char col = 'A' + j;
colorPrint(std::string(1, col) + " ", 7);
}
std::cout << "\n";
// 行号和棋盘
for(int i = 0; i < SIZE; i++) {
colorPrint(std::to_string(i+1), 7);
if(i+1 < 10) cout << " ";
for(int j = 0; j < SIZE; j++) {
if(board[i][j] == 'X') {
colorPrint("● ", FOREGROUND_RED | FOREGROUND_INTENSITY);
} else if(board[i][j] == 'O') {
colorPrint("○ ", FOREGROUND_BLUE | FOREGROUND_INTENSITY);
} else {
colorPrint("· ", 7);
}
}
std::cout << "\n";
}
std::cout << "\n";
};
auto checkWin = [&](int r, int c) -> bool {
char stone = board[r][c];
int directions[4][2] = {{0,1},{1,0},{1,1},{1,-1}};
for(auto& d : directions) {
int count = 1;
for(int k = 1; k < 5; k++) {
int nr = r + d[0]*k, nc = c + d[1]*k;
if(nr >= 0 && nr < SIZE && nc >= 0 && nc < SIZE && board[nr][nc] == stone) count++;
else break;
}
for(int k = 1; k < 5; k++) {
int nr = r - d[0]*k, nc = c - d[1]*k;
if(nr >= 0 && nr < SIZE && nc >= 0 && nc < SIZE && board[nr][nc] == stone) count++;
else break;
}
if(count >= 5) return true;
}
return false;
};
int moves = 0;
while(!gameOver) {
drawBoard();
std::cout << "玩家 " << currentPlayer << " 请落子 (格式: 行号 列号, 如 7 7): ";
int r;
char colChar;
if(!(std::cin >> r >> colChar)) {
std::cin.clear();
std::cin.ignore(10000, '\n');
colorPrint("输入格式错误,请重试!\n", FOREGROUND_RED);
system("pause");
continue;
}
r = r - 1;
int c = colChar - 'A';
if(r < 0 || r >= SIZE || c < 0 || c >= SIZE || board[r][c] != 0) {
colorPrint("无效位置,请重试!\n", FOREGROUND_RED);
system("pause");
continue;
}
board[r][c] = currentPlayer;
moves++;
if(checkWin(r, c)) {
drawBoard();
std::string msg = "玩家 " + std::string(1, currentPlayer) + " 获胜!\n";
colorPrint(msg, FOREGROUND_GREEN | FOREGROUND_INTENSITY);
gameOver = true;
} else if(moves >= SIZE * SIZE) {
drawBoard();
colorPrint("平局!\n", FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
gameOver = true;
} else {
currentPlayer = (currentPlayer == 'X') ? 'O' : 'X';
}
}
system("pause");
}
int main() {
// 设置中文编码
// system("chcp 65001 > nul");
srand(time(0));
SetConsoleTitleA("=== 极客控制台游戏区 V8.1 (终极完整版) ===");
// 初始化默认颜色为绿色(模仿黑客风格)
setGlobalColor(FOREGROUND_GREEN | FOREGROUND_INTENSITY);
int choice;
while (true) {
system("cls");
colorPrint("\n===== 控制台游戏区 =====\n", FOREGROUND_GREEN | FOREGROUND_INTENSITY);
std::cout << "[1] 改变控制台颜色 (系统级)\n";
std::cout << "[2] 隐藏/显示控制台窗口\n";
std::cout << "[3] 强制关闭指定程序\n";
std::cout << "[4] 测试关机 (60秒倒计时)\n";
std::cout << "[5] 呼叫伪AI (聊天/工具/即时编译代码)\n";
std::cout << "[6] 选择小游戏\n";
std::cout << "[0] 退出游戏区\n";
std::cout << "请输入选项: ";
std::cin >> choice;
std::cin.ignore();
if (choice == 1) {
printf("你想要换什么颜色"); // 这里的 color 命令是系统级的,会覆盖我们的设置
int news_color;
std::cin >> news_color;
if(news_color == 1) system("color 78");
if(news_color == 2) system("color 5A");
if(news_color == 3) system("color 3D");
if(news_color == 4) system("color 91");
if(news_color == 5) system("color AC");
if(news_color == 6) system("color FF");
}
else if (choice == 2) {
HWND hwnd = GetConsoleWindow();
ShowWindow(hwnd, SW_HIDE);
Sleep(1000);
ShowWindow(hwnd, SW_SHOW);
}
else if (choice == 3) {
std::string processName;
std::cout << "请输入要强制关闭的程序名 (例如: notepad.exe): ";
std::getline(std::cin, processName);
std::string cmd = "taskkill /F /IM " + processName;
system(cmd.c_str());
}
else if (choice == 4) {
std::string input;
system("shutdown -s -t 60");
colorPrint("警告:电脑将在 60 秒后关机!\n", FOREGROUND_RED | FOREGROUND_INTENSITY);
std::cout << "输入 'cancel' 取消关机: ";
std::cin >> input;
if (input == "cancel") {
system("shutdown -a");
colorPrint("关机已取消。\n", FOREGROUND_GREEN);
}
}
else if (choice == 5) {
fakeAI();
}
else if(choice == 6)
{
std::cout << "你要玩什么游戏?(1.猜数字 2.井字棋 3.反应力测试 4.五子棋)";
int df;
std::cin >> df;
if(df == 1)
{
gameGuessNumber();
}
else if(df == 2)
{
gameTicTacToe();
}
else if(df == 3)
{
gameReaction();
}
else if(df == 4)
{
gameGomoku();
}
}
else
{
return 0;
}
}
}
程序玩法
1. 更改控制台颜色:可以输入(1-6)改变颜色,6为改为原来的颜色(黑色)
2. 隐藏/显示控制台窗口:窗口隐藏3秒后会自动弹出
3. 强制关闭程序(大部分),如.exe文件
4. 关机:可以使计算机关机,输入cancel可取消
5. 伪AI用法:
1.输入:现在几点了?AI会报时
2.输入打开记事本/计算器/画图 打开对应软件
3.打开网站:输入打开网站+网站名(目前可以打开baidu,bilinili,github,acgo,画图)其他的网站需要加上https://www.
4.输入随机数,为你抽取随机数字
5.输入换个颜色,切换颜色
6输入编译,编译c++代码
7.基础·聊天
6游戏:有一些游戏
更新部分
1.伪AI可以进行运算了 输入“运算”+空格+ 算式(这里用的是op双栈模拟,依旧自己懒得写)(支持(),+,-,*,/)
2.伪AI可以进行艺术字生成 输入:“艺术字”+空格+ 需要生成的字(必须为英文)
全部评论 7



1周前 来自 浙江
0



1周前 来自 浙江
0d
2026-08-06 来自 浙江
0d
2026-08-06 来自 浙江
0d
2026-08-06 来自 浙江
0不是我写的哈,承认是用AI
2026-08-06 来自 浙江
0


2026-08-06 来自 浙江
0抄袭我
2026-08-06 来自 浙江
0诶那真的是纯属雷同???
2026-08-06 来自 浙江
0可以可以原来是雷同,我以为伪AI是我想出来的词语呢,原来还有人和我志同道合!
2026-08-06 来自 浙江
0

























有帮助,赞一个