好的,我可以帮助你写一个猜数字小游戏,用C++代码实现: #include <iostream>
#include <cstdlib>
#include <ctime> using namespace std; int main()
{
srand((unsigned)time( 微型小飞机 NULL ));
微型小飞机
int number = rand() % 100 + 1;
int guess;
cout << "猜一个1到100的数字:";
cin >> guess;
while (guess != number)
{
if (guess > number)
微型小飞机 cout << "你猜的太高了!" << endl;
else
cout << "你猜的太低了!" << endl;
cout << "再猜一次:";
cin >> guess;
}
cout << "恭喜你!答案正确!" << endl;
return 0;
}