#include <iostream>
#include <time.h>
const int min =2;
const int max =100;
int main()
{
using namespace std;
srand(time(NULL));
int start = 1;
int end = 100;
int count =0;
int du;
int a;
a = (rand() % (max-min)+min) ;
cout << "请输入" << start << " ~ " << end <<"之间的数: ";
cin >> du;
do
{
if(du > a && du > start && du < end)
{
end = du;
cout << "请输入" << start << " ~ " << end <<"之间的数: ";
cin >> du;
}
else if(du<a && du > start && du < end)
{
start = du;
cout << "请输入" << start << " ~ " << end <<"之间的数: ";
cin >> du;
}
else if(du ==a)
break;
else
{
cout << endl;
cout << "请遵守游戏规则!" <<endl;
cout << "请输入" << start << " ~ " << end <<"之间的数: ";
cin.clear();
while(cin.get() == '\n')
{
continue;
}
cin >> du;
}
}while(du != a);
cout << "恭喜你中奖了" << endl;
return 0;
}
#include <time.h>
const int min =2;
const int max =100;
int main()
{
using namespace std;
srand(time(NULL));
int start = 1;
int end = 100;
int count =0;
int du;
int a;
a = (rand() % (max-min)+min) ;
cout << "请输入" << start << " ~ " << end <<"之间的数: ";
cin >> du;
do
{
if(du > a && du > start && du < end)
{
end = du;
cout << "请输入" << start << " ~ " << end <<"之间的数: ";
cin >> du;
}
else if(du<a && du > start && du < end)
{
start = du;
cout << "请输入" << start << " ~ " << end <<"之间的数: ";
cin >> du;
}
else if(du ==a)
break;
else
{
cout << endl;
cout << "请遵守游戏规则!" <<endl;
cout << "请输入" << start << " ~ " << end <<"之间的数: ";
cin.clear();
while(cin.get() == '\n')
{
continue;
}
cin >> du;
}
}while(du != a);
cout << "恭喜你中奖了" << endl;
return 0;
}