HUST Online Judge WebBoard
[ New Thread ]
Problem 1111 >> 猜数字:
2020zjhj11 @ 2021-04-09 21:43:28
[ Quote ] [ Edit ] [ Delete ] 1#
#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;
}
2020zjhj11 @ 2021-04-09 21:52:49
[ Quote ] [ Edit ] [ Delete ] 2#
!!
2020zjhj11 @ 2021-04-09 21:54:16
[ Quote ] [ Edit ] [ Delete ] 3#
https://www.ixigua.com/home/2576882254753688/?wid_try=1
!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!
shengbinhao @ 2021-04-13 19:56:00
[ Quote ] [ Edit ] [ Delete ] 4#
hhhh
cjy2011 @ 2021-04-13 21:23:29
[ Quote ] [ Edit ] [ Delete ] 5#

2020zjhj11 @ 2021-04-15 20:28:03
[ Quote ] [ Edit ] [ Delete ] 6#
你们看过《熊小欠的故事》吗?
没看过的同学可以复制下面的
2020zjhj11 @ 2021-04-15 20:33:35
[ Quote ] [ Edit ] [ Delete ] 7#
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
2020zjhj11 @ 2021-04-15 20:34:35
[ Quote ] [ Edit ] [ Delete ] 8#
( ̄︶ ̄)↗ ( ̄︶ ̄)↗ ( ̄︶ ̄)↗ ( ̄︶ ̄)↗ ( ̄︶ ̄)↗ 
(❤´艸`❤)(❤´艸`❤)(❤´艸`❤)(❤´艸`❤)(❤´艸`❤)(❤´艸`❤)(❤´艸`❤)
2020zjhj11 @ 2021-04-15 20:35:48
[ Quote ] [ Edit ] [ Delete ] 9#
喜欢发1;
不喜欢发0;
2020zjhj11 @ 2021-04-15 20:36:22
[ Quote ] [ Edit ] [ Delete ] 10#
其它发666
2020zjhj11 @ 2021-04-15 20:37:43
[ Quote ] [ Edit ] [ Delete ] 11#
4月20日更新........
gugu @ 2021-04-18 16:01:15
[ Quote ] [ Edit ] [ Delete ] 12#
666
13819598059 @ 2021-04-19 21:11:49
[ Quote ] [ Edit ] [ Delete ] 13#
升级版


#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;
}
[Top] [Previous Page] [Next Page]