猜数
来源:互联网 发布:菜瓜软件 编辑:程序博客网 时间:2024/06/03 21:23
/*
*Copyright(c)2014,烟台大学计算机与控制工程学院
*All rights reserved.
*文件名称:asd.cpp
*作 者:綦鹏
*完成日期:2016年3月28日
*版 本 号:v1.0
*
*问题描述:猜数
*输入描述:1000以内的数
*程序输出;偏大及偏小 以及猜的次数
*/
#include <iostream>
#include<ctime>
#include<cstdlib>
using namespace std;
int main()
{
int x,y,t=0;
int i;
srand(time(0));
x=rand()%1000;
cout<<"请猜取1000以内的一个数"<<endl;
for(i=0;i<1000;i++)
{
cin>>y;
if(y>x)
{
cout<<"大了"<<endl;
t++;
}
else if(y<x)
{
cout<<"小了"<<endl;
t++;
}
else
{
cout<<"对了"<<endl;
break;
}
}
cout<<"经过"<<t<<"次后猜对了"<<endl;
return 0;
}
*Copyright(c)2014,烟台大学计算机与控制工程学院
*All rights reserved.
*文件名称:asd.cpp
*作 者:綦鹏
*完成日期:2016年3月28日
*版 本 号:v1.0
*
*问题描述:猜数
*输入描述:1000以内的数
*程序输出;偏大及偏小 以及猜的次数
*/
#include <iostream>
#include<ctime>
#include<cstdlib>
using namespace std;
int main()
{
int x,y,t=0;
int i;
srand(time(0));
x=rand()%1000;
cout<<"请猜取1000以内的一个数"<<endl;
for(i=0;i<1000;i++)
{
cin>>y;
if(y>x)
{
cout<<"大了"<<endl;
t++;
}
else if(y<x)
{
cout<<"小了"<<endl;
t++;
}
else
{
cout<<"对了"<<endl;
break;
}
}
cout<<"经过"<<t<<"次后猜对了"<<endl;
return 0;
}
0 0
- 猜数
- 猜数
- 猜数
- 猜数
- 猜数
- 猜数
- 猜数
- 猜数
- 猜数
- 鬼谷子 猜数问题
- 猜数游戏程序
- 计算机猜数解答
- 计算机猜数算法
- 人机猜数游戏
- 1995猜数游戏
- Java猜数游戏
- 猜数游戏
- 猜数游戏
- KMP字符串匹配算法
- 详解mysql int类型的长度值问题
- mysql数据库sql优化原则
- shell教程二: shell中的$
- java、运算
- 猜数
- java反转链表
- GitHub Top 100的Android开源库
- hdu4786(最小生成树)
- Python学习 准备工作
- MySQL同时执行多条查询
- eclipse开发Android之Android的项目结构
- LeetCode105—Construct Binary Tree from Preorder and Inorder Traversal
- android 加载大图片