#include<iostream>
using namespace std;
int main()
{
int i;
int n;
cin >> n;
while (n)
{
i = rand()%100;
if(i == n)
{
else if(n>i)
{
cout << "high" << endl;
}
else
{
cout << "low" << endl;
}
cin >> n;
}
system("pause");
return 0;
}
using namespace std;
int main()
{
int i;
int n;
cin >> n;
while (n)
{
i = rand()%100;
if(i == n)
{
cout << "right!" << endl;
break;
}else if(n>i)
{
cout << "high" << endl;
}
else
{
cout << "low" << endl;
}
cin >> n;
}
system("pause");
return 0;
}
本文介绍了一个简单的猜数字游戏程序,使用C++语言编写。程序通过随机生成一个0到99之间的整数,让玩家尝试猜测这个数字。每轮猜测后,程序会提示玩家猜的数字是过高还是过低,直至猜中为止。

被折叠的 条评论
为什么被折叠?



