用户:
夜明逢生查看:0 回复:1 评论:0 创建时间:2023-07-21T22:44:52
自学三天的作品
#include <iostream>
#include <cstdlib>
#include <cstdlib>
using namespace std;
int main()
{
int a,b = 0,c,d,f = 0;
bool e;
for (b = 1;b < 5;b++)
{
cout << " 第" << b << "道题目 分数:" << f << "分" << endl;
srand(time(0));
a = rand()%5+1;
for (d = 0;d < 3;d++)
{
e = false;
cout << "请输入你所猜的数字:";
cin >> c;
if (c == a)
{
e = true;
break;
}
else if (c > a)
cout << "太大了" << endl;
else if (c < a)
cout << "太小了" << endl;
cout << " 还剩" << 3 - d << "机会" << endl;
}
if (e)
{
cout << "你答对了" << endl;
f ++;
}
else
cout << "你的机会用完了 进入下一题" << endl;
cout << "" << endl;
}
cout << " 恭喜你通关了 你获得了分数:" << f << "分" << endl;
return 0;
}