用c++语言实现猜测1-100的某个数
题目详情:
题解:
题目的解答就在题目要求中,代码实现如下:
#include<iostream>
using namespace std;
int main()
{ Random rdm= new Random();
int guess =rdm.Next(0,101)
for (int i = 1; i < 101; i++)
{
cout << "第"<<i<<"次猜,请输入一个整形数" << endl;
cin >> x;
if (guess >x )
cout << "太小" << endl;
if (x>guess)
cout << "太大" << endl;
if (x == guess)
{
cout << "恭喜你猜对了,这个数是" << y << endl;
break;
}
}
return 0;
}