真心话大冒险代码c++
时间: 2023-07-09 17:10:37 浏览: 115
以下是一个简单的C++实现真心话大冒险的代码,仅供参考:
```
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <vector>
using namespace std;
int main() {
srand(time(NULL)); // 设置随机数种子
vector<string> truths = { "你有没有偷看过别人的手机?", "你有没有撒谎过?", "你有没有喜欢过你的同桌?", "你有没有做过梦,梦到你喜欢的人?", "你有没有在考试的时候作弊过?", "你有没有打算过逃学?" };
vector<string> dares = { "唱一首歌", "做一个鬼脸", "蹦几个跳跳球", "模仿小猪佩奇", "做一个空翻", "跳一段舞" };
int choice;
while (true) {
cout << "请选择:1.真心话 2.大冒险 3.退出" << endl;
cin >> choice;
if (choice == 1) { // 真心话
int index = rand() % truths.size();
cout << truths[index] << endl;
}
else if (choice == 2) { // 大冒险
int index = rand() % dares.size();
cout << dares[index] << endl;
}
else if (choice == 3) { // 退出
cout << "游戏结束!" << endl;
break;
}
else { // 输入错误
cout << "输入有误,请重新输入!" << endl;
}
}
return 0;
}
```
注意:真心话和大冒险的问题需要自己定义,以上代码中只是作为示例使用。