/*
*烟台大学计算机学院
*文件名称:main.cpp
*作 者:王者健
*完成日期:2016年6月11日
*版 本 号:codeblocks 16.01
*/
#include <iostream>
using namespace std;
#include<ctime>
#include<cstdlib>
int main()
{
int n,m,g=0;
srand((unsigned)time(0));
n=1+rand()%1000;
for(;;)
{
cout<<"please input a number:"<<endl;
cin>>m;
g++;
if(m>n)
{
cout<<"大了"<<endl;
}
else if(m<n)
{
cout<<"小了"<<endl;
}
else
{
cout<<"猜对啦"<<endl<<"一共才对了"<<g<<"次"<<endl;
break;
}
}
return 0;
}
猜大小
最新推荐文章于 2023-08-02 14:54:41 发布