猜数字
来源:互联网 发布:快速买火车票软件 编辑:程序博客网 时间:2024/06/11 20:51
* Copyright (c) 2013, 烟台大学计算机学院
* All rights reserved.
* 作 者: 李中意
* 完成日期:2013 年11 月19 日
* 版 本 号:v1.0 *
* 问题描述:电脑随机出一个数(1000以内的),机主多次猜测,电脑会根据所猜数与随机数的关系给出大了,小了。直到猜对为止。
* 问题分析:用do while语句
#include <iostream>#include <cstdlib>#include <ctime>using namespace std;int main(){ int ran_num,a; srand(time(0)); cout<<"请输入一个数"<<endl; a=rand()%1000; do { cin>>ran_num; if(ran_num<a) { cout<<"小了"<<endl; } else if(ran_num>a) { cout<<"大了"<<endl; } else { cout<<"该数是"<<ran_num<<endl; } } while(ran_num=rand()); return 0;}
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- 猜数字
- linux串口编程详解
- linux下安装flash插件安装jdk安装tomcat安装eclipse安装mysql
- VB.NET可选参数例子
- RSA DSA DEMO
- Windows Store 平台移植 —— (8)C,C++库构建
- 猜数字
- struts中配置action
- 使用nodejs创建一个网站-重构代码
- org.apache.hadoop.io.compress源码解读
- viewData与ViewBag的区别
- 对XP上的KiFastSystemCall进行浅析
- linux网络编程基础
- DP:背包问题 Knapsack Problem
- Android ListView和CheckBox应用之批量删除操作