"up主在一次游戏中被困,在一场惊险刺激的逃脱游戏中,一步步接近真相,经历了一系列令人毛骨悚然的经历。
#include <iostream> #include <cstdlib> #include <ctime> #include <unistd.h> #define_MANY 4 #define TIME_OUT 8 int a, b, u; void game() { int input = rand() % Many + 1; while(input != 1 || input != 2 || input != 3) { std::cout << "欢迎来到恐怖游戏旅程\n"; std::cout << "/t/t/t/t简单的猜数字游戏\n" << "/t/t/t/t1.开始游戏\n" << "/t/t/t/t2.使用说明\n" << "/t/t/t/t3.退出\n"; std::cout << "请输入(1-3): "; scanf("%d", &input); std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); } if(input == 1) { std::cout << "游戏开始了,\n"; for(int i = 1; i <= Many; ++i) { for(int j = 1; j <= Many; ++j) { int k = rand() % Many * 2 + 1; if(k == input && (k % Many) == 0) { std::cout << "答案是:" << k << std::endl; std::cout << "位置是:" << i << ", " << j << std::endl; std::cout << "你是第几个?" << std::endl; break; } } } std::cout << "恭喜你赢了!\n"; } else if(input == 2) { std::cout << "欢迎使用本程序,\n" << "作者:烈冰\n" << "游戏说明: 输入%d位数字,输入后会有提示XaYb,X表示有几", Many << "\n" << "个数字与答案数字相同\n" << "且位置正确,Y表示有几位数字与答案数字相同但位置不正确,答案数字是:" << Many << "\n" << "答案数字是:" << Many << "\n" << "恭喜你获胜!\n"; std::cout << "按任意键返回主目录……\n"; getch(); } else if(input == 3) { std::cout << "感谢您的参与,\n" << "我们很遗憾地通知您,游戏已经结束,\n" << "非常感谢您的支持,\n"; return; } } void ab(int answer[], int guess[]) { int index = find(answer, guess, Many); if(index == Many) { std::cout << "恭喜你通过了关卡!\n"; return; } printf("这个数字是:%d,正确的答案应该是:%d,\n", guess[index], answer[index]); } void same(int num[]) { int result = 0; for(int i = 0; i < Many; ++i) { if(num[i] == Many && i % Many == 0) { result++; } } std::cout << "恭喜你过关了!结果是:" << result << "\n"; } // 主函数 int main() { game(); return 0; }
0