当前位置:网站首页>Guess the number / / generate a random number for the first time
Guess the number / / generate a random number for the first time
2022-07-29 07:06:00 【Meat loving Xiaobai】

The code is as follows :
#include<iostream>
#include<ctime>// The function uses the current system time to generate random numbers , Prevent random numbers from being the same
using namespace std;
int main(void)
{
srand((unsigned int)time(NULL));
int num = rand() % 100 + 1;
cout << " Please enter 0 - 100 The random number guessed by :";
int num2;// The user enters the created variable
int num3 = 0;
while (1)
{
cin >> num2;
if (num2 > num)
{
cout << " Small handkerchief , The guessed number is greater than the random number :";
num3++;
}
else if (num2 < num)
{
cout << " Small handkerchief , The guessed number is less than the random number :";
num3++;
}
else
{
cout << " It was used "<< num3 <<" Second guess right , Small handkerchief , No way !";
break;//break Used to skip the loop
}
}
return 0;
}
边栏推荐
- Analog volume leetcode [normal] 093. Restore IP address
- Salesforce中过滤器Filter使用的相对日期
- Dbasql interview questions
- 【C语言刷LeetCode】1054. 距离相等的条形码(M)
- Flink real-time warehouse DWD layer (processing complex data - installation and replacement of streams and tables) template code
- buck电路boot和ph引脚实测
- Junda technology | applicable to "riyueyuan" brand ups wechat cloud monitoring card
- Simulation volume leetcode [normal] 061. rotating linked list
- Teacher wangshuyao's notes on operations research 01 guidance and introduction
- Teacher wangshuyao's notes on operations research 06 linear programming and simplex method (geometric significance)
猜你喜欢

buck电路boot和ph引脚实测

怎么会不喜欢呢,CICD中轻松发送邮件

外包干了3年,跳槽后转自动化测试工资是原来的2倍,秘诀原来是......

Unity free element special effect recommendation

leetcode-592:分数加减运算

Actual combat! Talk about how to solve the deep paging problem of MySQL

游戏资产的革命

vim文本编辑器的一些使用小技巧

Teacher wangshuyao's notes on operations research 04 fundamentals of linear algebra

Flink real time warehouse DWD layer (traffic domain) template code
随机推荐
MutationObserver文档学习
VMware16创建虚拟机:无法创建新虚拟机,不具备执行此操作的权限
图像加噪声与矩阵求逆
Overview of database system
win11VMware打开虚拟机就蓝屏重启以及启动不了的解决方案
怎么会不喜欢呢,CICD中轻松发送邮件
Decompilation of wechat applet
[C language brush leetcode] 2332. The latest time to get on the bus (m)
[C language brush leetcode] 67. binary sum (E)
Summary of 2022 SQL classic interview questions (with analysis)
Simulation volume leetcode [general] 150. evaluation of inverse Polish expression
新同事写了几段小代码,把系统给搞崩了,被老板爆怼一顿!
Not so simple singleton mode
分享一些你代码更好的小建议,流畅编码提搞效率
Teacher wangshuyao's notes on operations research 04 fundamentals of linear algebra
【C语言刷LeetCode】1054. 距离相等的条形码(M)
线程同步—— 生产者与消费者、龟兔赛跑、双线程打印
二次元卡通渲染——进阶技巧
实现改变一段文字的部分颜色效果
Record - step on the pit - real-time data warehouse development - doris/pg/flink