- 分享
基础操作系统
- @ 2025-7-3 19:03:35
#include<bits/stdc++.h>
using namespace std;
int i, g, h, k;
int b, c, d, e;
int f[30], a[30];
string j;
void bf() {
system("color 07");
cout << "hello word" << endl << "1*exit" << endl << "2*open my computer" << endl << "3*sleep" << endl << "game"<<endl;
cin >> g;
switch (g) {
case 1:
return;
break;
case 2:
system("cls");
cout << "1*witer txt" << "2*new.txt";
cin >> h;
switch (h) {
case 1:
system("cls");
cin >> j;
bf();
break;
case 2:
system("cls");
cout << j;
cin >> k;
if (k == 1) {
bf();
k = 0;
}
break;
}
break;
case 3:
system("cls");
cin >> k;
if (k == 1) {
bf();
k = 0;
}
break;
case 4:
system("cls");
system("color fa");
srand(time(0));
b = rand() % 50 + 1;
c = rand() % 50 + 1;
d = rand() % 50 + 1;
e = rand() % 50 + 1;
for (int i = 0; i < 30; i++) {
cin >> a[i];
if (a[i] < 1 || 50 < a[i] || a[i] != (int)a[i]) {
system("color c4");
cout << "you did";
}
f[i] = a[i];
if (a[i] == b) {
cout << "you did" << endl;
system("color ce");
system("pause");
system("cls");
i -= 2;
}
if (a[i] == c) {
cout << "win+1" << endl;
system("color de");
system("pause");
system("cls");
i += 5;
}
if (a[i] == d) {
system("color c4");
cout << "you did" << endl;
system("pause");
system("cls");
cout << "win+1:" << c << endl;
cout << "did1:" << b << endl;
cout << "did2:" << d << endl;
cout << "win:" << e << endl;
}
if (a[i] == e) {
cout << "you win" << endl;
system("color e1");
system("pause");
system("cls");
break;
}
cout << "nixt" << endl;
}
cout << "you win" << endl;
system("pause");
system("cls");
cout << "win+1:" << c << endl;
cout << "did1:" << b << endl;
cout << "did2:" << d << endl;
cout << "win:" << e << endl;
break;
}
}
void fun() {
system("color ce");
cout << "#";
system("color de");
system("color c4");
system("color e1");
i++;
if (i < 1000) {
fun();
}
system("cls");
cout << "OK!";
system("pause");
bf();
}
int main() {
fun();
}
5 条评论
-
-
#include <iostream> #include <cstdlib> #include <ctime> #include <string> #include <limits> using namespace std; // 全局变量 string inputText; int gameNumbers[4]; // 存储游戏的四个随机数 // 清屏函数(跨平台) void clearScreen() { #ifdef _WIN32 system("cls"); #else system("clear"); #endif } // 设置控制台颜色(Windows) void setColor(int color) { #ifdef _WIN32 system(("color " + to_string(color)).c_str()); #endif } // 加载动画(改用循环避免栈溢出) void loadingAnimation() { setColor(0xCE); for (int i = 0; i < 100; i++) { cout << "#"; if (i % 20 == 0) cout << endl; } clearScreen(); cout << "OK!" << endl; system("pause"); } // 游戏初始化 void initGame() { srand(time(0)); gameNumbers[0] = rand() % 50 + 1; // b - 失败1 gameNumbers[1] = rand() % 50 + 1; // c - 胜利+1 gameNumbers[2] = rand() % 50 + 1; // d - 失败2 gameNumbers[3] = rand() % 50 + 1; // e - 胜利 // 确保四个数不重复 for (int i = 0; i < 4; i++) { for (int j = i + 1; j < 4; j++) { if (gameNumbers[i] == gameNumbers[j]) { gameNumbers[j] = rand() % 50 + 1; j = i; // 重新检查 } } } } // 游戏主逻辑 void playGame() { clearScreen(); setColor(0xFA); initGame(); cout << "欢迎来到猜数字游戏!" << endl; cout << "规则:" << endl; cout << "1. 输入1-50之间的数字" << endl; cout << "2. 找到胜利数字即可获胜" << endl; cout << "3. 小心失败数字!" << endl; cout << "------------------------" << endl; int userInput; int attempts = 0; while (true) { cout << "\n请输入数字(1-50):"; while (!(cin >> userInput) || userInput < 1 || userInput > 50) { cin.clear(); cin.ignore(numeric_limits<streamsize>::max(), '\n'); cout << "输入无效!请输入1-50之间的整数:"; } attempts++; if (userInput == gameNumbers[3]) { // 胜利数字 setColor(0xE1); cout << "恭喜你!猜对了胜利数字,游戏胜利!" << endl; break; } else if (userInput == gameNumbers[1]) { // 胜利+1 setColor(0xDE); cout << "不错!找到加分数字,继续前进!" << endl; } else if (userInput == gameNumbers[0]) { // 失败1 setColor(0xCE); cout << "哎呀!踩到失败数字了,重来一次!" << endl; attempts = 0; } else if (userInput == gameNumbers[2]) { // 失败2 setColor(0xC4); cout << "游戏结束!你踩到了陷阱数字!" << endl; cout << "\n游戏结果:" << endl; cout << "胜利+1数字:" << gameNumbers[1] << endl; cout << "失败数字1:" << gameNumbers[0] << endl; cout << "失败数字2:" << gameNumbers[2] << endl; cout << "胜利数字:" << gameNumbers[3] << endl; break; } else { cout << "继续尝试..."; } } cout << "\n总尝试次数:" << attempts << endl; system("pause"); } // 文本编辑功能 void textEditor() { clearScreen(); cout << "文本编辑器" << endl; cout << "1. 输入文本" << endl; cout << "2. 查看文本" << endl; cout << "3. 返回主菜单" << endl; int choice; cout << "\n请选择:"; cin >> choice; switch (choice) { case 1: clearScreen(); cout << "请输入文本(输入END结束):" << endl; cin.ignore(); getline(cin, inputText, 'E'); // 以'E'作为结束符 inputText += "ND"; // 补全END cout << "文本已保存!" << endl; system("pause"); textEditor(); break; case 2: clearScreen(); cout << "当前文本:" << endl; cout << inputText << endl; cout << "\n按1返回编辑菜单:"; cin >> choice; if (choice == 1) textEditor(); break; case 3: return; default: cout << "无效选择!" << endl; system("pause"); textEditor(); } } // 休眠模式 void sleepMode() { clearScreen(); cout << "休眠模式..." << endl; cout << "按1唤醒:"; int wake; cin >> wake; if (wake == 1) return; } // 主菜单 void mainMenu() { setColor(0x07); // 默认颜色 while (true) { clearScreen(); cout << "===== 主菜单 =====" << endl; cout << "1. 退出程序" << endl; cout << "2. 文本编辑器" << endl; cout << "3. 休眠模式" << endl; cout << "4. 猜数字游戏" << endl; cout << "==================" << endl; int choice; cout << "\n请选择功能:"; while (!(cin >> choice) || choice < 1 || choice > 4) { cin.clear(); cin.ignore(numeric_limits<streamsize>::max(), '\n'); cout << "输入无效!请输入1-4之间的数字:"; } switch (choice) { case 1: cout << "感谢使用,再见!" << endl; exit(0); case 2: textEditor(); break; case 3: sleepMode(); break; case 4: playGame(); break; } } } int main() { loadingAnimation(); mainMenu(); return 0; } -
thank you 是你给我的灵感☺☺☺ plus:```language #include<bits/stdc++.h> using namespace std; int i, g, h, k; int b, c, d, e; int f[30], a[30]; string j; void bf() { system("cls"); system("color 17"); cout << "hello word" << endl << "1exit" << endl << "2open my computer" << endl << "3sleep" << endl << "4game" << endl; cin >> g; switch (g) { case 1: return; break; case 2: system("cls"); cout << "1witer txt" << endl << "2new.txt" << endl; cin >> h; switch (h) { case 1: system("cls"); cin >> j; bf(); break; case 2: system("color 17"); system("cls"); cout << j; cin >> k; if (k == 0) { bf(); k = 0; } break; } break; case 3: system("cls"); cin >> k; if (k == 0) { bf(); k = 0; } break; case 4: system("cls"); system("color 17"); srand(time(0)); b = rand() % 50 + 1; c = rand() % 50 + 1; d = rand() % 50 + 1; e = rand() % 50 + 1; for (int i = 0; i < 30; i++) { cin >> a[i]; if (a[i] < 1 || 50 < a[i] || a[i] != (int)a[i]) { system("color c4"); cout << "you did"; bf();
} f[i] = a[i]; if (a[i] == b) { cout << "you did" << endl; system("color ce"); system("pause"); system("cls"); i -= 2; } if (a[i] == c) { cout << "win+1" << endl; system("color de"); system("pause"); system("cls"); i += 5; } if (a[i] == d) { system("color c4"); cout << "you did" << endl; system("pause"); system("cls"); cout << "win+1:" << c << endl; cout << "did1:" << b << endl; cout << "did2:" << d << endl; cout << "win:" << e << endl; } if (a[i] == e) { cout << "you win" << endl; system("color e1"); system("pause"); system("cls"); break; } cout << "nixt" << endl; } cout << "you win" << endl; system("pause"); system("cls"); cout << "win+1:" << c << endl; cout << "did1:" << b << endl; cout << "did2:" << d << endl; cout << "win:" << e << endl; break; }} void fun() { cout << "#"; system("color 17"); system("color 17"); system("color 17"); system("color 17"); system("color 17"); system("color 17"); system("color 17"); system("color 17"); system("color 17"); system("color 17"); system("color 17"); system("color 17"); system("color 17"); system("color 17"); system("color 17"); system("color 17"); system("color 17"); system("color 17");
i++; if (i < 100) { fun(); } system("cls"); cout << "OK!"; system("pause"); bf();} int main() { fun(); }//thank you
-
@ 2025-7-3 19:20:33中文版:
#include<bits/stdc++.h> using namespace std; int main(){ int b,c,d,e; int f[30],a[30]; system("color fa"); srand(time(0)); b=rand()%50+1; c=rand()%50+1; d=rand()%50+1; e=rand()%50+1; cout<<"**数字炸弹**"<<endl<<"规则:"<<endl<<"1.不能输入比50大的数"<<endl<<"2.不能输入比1小的数"<<endl<<"3.不能输入字母"; for(int i=0;i<30;i++){ cin>>a[i]; if(a[i]<1||50<a[i]||a[i]!=(int)a[i]){ system("color c4"); cout<<"你死了"; return 0; } f[i]=a[i]; for(int j=0;j<30;j++){ if(f[j]==a[i]&&i!=j){ cout<<"不能输入同样的数"<<a[i]<<"!"; i--; } } if(a[i]==b){ cout<<"你抽到炸弹卡了!"<<endl; system("color ce"); system("pause"); system("cls"); i-=2; } if(a[i]==c){ cout<<"恭喜你抽到了神秘道具!"<<endl; system("color de"); system("pause"); system("cls"); i+=5; } if(a[i]==d){ system("color c4"); cout<<"你抽到核弹死了。"<<endl; system("pause"); system("cls"); cout<<"神秘道具是:"<<c<<endl; cout<<"炸弹是:"<<b<<endl; cout<<"核弹是:"<<d<<endl; cout<<"万能卡是:"<<e<<endl; return 0; } if(a[i]==e){ cout<<"你抽到万能卡赢了!"<<endl; system("color e1"); system("pause"); system("cls"); break; } cout<<"你没死!"<<endl; } cout<<"你赢了!"<<endl; system("pause"); system("cls"); cout<<"神秘道具是:"<<c<<endl; cout<<"炸弹是:"<<b<<endl; cout<<"核弹是:"<<d<<endl; cout<<"万能卡是:"<<e<<endl; return 0; }(这是我编的)
- 1