|
Problem 1111 >> 猜数字: |
|
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main() {
cout << "我这里有一个数,现在请你猜猜它"<<endl;
srand(time(NULL));
int x = rand() % 50;
for (int i =1;i <= 7;i++){
int y;
cin >> y;
if (y<x) {
cout << "不好意思,你猜小了" << endl;
}else if (y>x) {
cout << "对不起,你猜大了" <<endl;
}else {
cout << "恭喜恭喜,猜对了!!!" << endl;
return 0;
}
}
cout << "你的次数用完了,你失败了"<<endl<<"那个数是"<<x;
return 0;
}
|
|
!!
|
|
https://www.ixigua.com/home/2576882254753688/?wid_try=1
!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!
|
|
hhhh
|
|
牛
|
|
你们看过《熊小欠的故事》吗?
没看过的同学可以复制下面的
|
|
https://www.ixigua.com/home/2576882254753688/?wid_try=1
https://www.ixigua.com/home/2576882254753688/?wid_try=1
https://www.ixigua.com/home/2576882254753688/?wid_try=1
|
|
( ̄︶ ̄)↗ ( ̄︶ ̄)↗ ( ̄︶ ̄)↗ ( ̄︶ ̄)↗ ( ̄︶ ̄)↗
(❤´艸`❤)(❤´艸`❤)(❤´艸`❤)(❤´艸`❤)(❤´艸`❤)(❤´艸`❤)(❤´艸`❤)
|
|
喜欢发1;
不喜欢发0;
|
|
其它发666
|
|
4月20日更新........
|
gugu @ 2021-04-18 16:01:15
666
|
|
升级版
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
void menu()
{
printf("******************************\n");
printf("********** 1.猜数字************\n");
printf("********** 0.离开************\n");
printf("******************************\n");
}
void game()
{
int rand_num = rand() % 100 + 1;
int input = 0;
int count = 0;
while (1)
{
printf("\n不妨猜一下我现在心里想的是哪个数字:>");
scanf("%d", &input);
if (input < rand_num)
{
printf("\n猜小了!");
count++;
}
else if (input>rand_num)
{
printf("\n猜大了!");
count++;
}
else
{
count++;
printf("卧槽,你是我心里的蛔虫吗?!哼,猜中了也没有奖励!游戏结束,不玩啦");
printf("\n你一共猜了%d次",count);
break;
}
}
printf("\n");
}
int main()
{
int input = 0;
srand((unsigned)time(NULL));
do
{
menu();
printf("请选择:>");
scanf("%d", &input);
switch (input)
{
case 1:
game();
break;
case 0:
break;
default:
printf("\n请重新输入!\n");
break;
}
} while (input);
system("pause");
return 0;
}
|