/* Copyright (c) 2016
* All rights reserved
* 文件名称:3.cpp
* 作者:刘丽
* 完成日期:2016年 3 月 17日
* 版本号: v1.0
*
* 问题描述:随机产生一个1000以内的数字,要求用户猜测这个整数,大了就输出“大了”,小了就输出小了,直到用户才对。
*
*输入描述:一个整数,m
* 程序输出:字符串。
*/
#include<iostream>
#include<stdlib.h>
#include <time.h>
using namespace std;
int main()
{
int n,m;
srand(time(0));
n=rand()%1000;
cout<<"请猜一个数"<<endl;
while(1)
{
cin>>m;
if(m>n)
cout<<"大了"<<endl;
else if(m<n)
cout<<"小了"<<endl;
else break;
}
cout<<"猜对了"<<endl;
return 0;
}