猜数字游戏

#define _CRT_SECURE_NO_WARNINGS
//猜数字游戏
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
//void menu()
//{
//	printf("***************************\n");
//	printf("******   1.play   *********\n");
//	printf("******   0.exit   *********\n");
//	printf("***************************\n");
//
//}
//
//void play()
//{
//	int c = 100 + rand() % 101;
//	int r = 0;
//	while (1)
//	{
//		printf("请输入你要猜的数\n");
//		scanf("%d", &r);
//		if (r > c)
//		{
//			printf("猜大了\n");
//		}
//		else if (r < c)
//		{
//			printf("猜小了\n");
//		}
//		else
//		{
//			printf("猜对了,数字为%d\n", r);
//			break;
//		}
//	}
//	
//}
//
//int main()
//{
//	int input;
//	srand((unsigned int)time(NULL));
//	do
//	{
//		menu();
//		scanf("%d", &input);
//		if (input == 1)
//		{
//			printf("游戏开始\n");
//			play();
//		}
//		else if (input == 0)
//		{
//			printf("退出游戏\n");
//			
//		}
//		else
//		{
//			printf("输入错误\n");
//		}
//
//	} while (input);
//	return 0;
//}






//加大挑战,减少为5次机会


//void menu()
//{
//	printf("***************************\n");
//	printf("******   1.play   *********\n");
//	printf("******   0.exit   *********\n");
//	printf("***************************\n");
//
//}
//
//void play()
//{
//	int count = 7;
//	int r = 100 + rand()%101;
//	while (count)
//	{
//		int c = 0;
//		printf("请输入你要输入的数\n");
//		scanf("%d",&c);
//		if (c > r)
//		{
//			printf("猜大了\n");
//			count--;
//		}
//		else if (c < r)
//		{
//			printf("猜小了\n");
//			count--;
//		}
//		else
//		{
//			printf("恭喜你,猜对了,数字是%d",c);
//		}
//	}
//	if (count == 0)
//	{
//		printf("游戏失败\n");
//	}
//}
//
//int main()
//{
//	int input = 0;//不可放入do while 循环内,因为出来后while循环的作用域释放了,然后while(input)的时候就找不到;1
//	srand((unsigned int)time(NULL));
//	do//可以多次玩
//	{
//		menu();
//		printf("请输入\n");
//		scanf("%d",&input);
//		if (input == 1)
//		{
//			printf("游戏开始\n");
//			play();
//		}
//		else if (input == 0)
//		{
//			printf("退出游戏\n");
//			break;
//		}
//		else
//		{
//			printf("输入错误,请重新输入\n");
//		}
//	} while (input);
//	return 0;
//}






//可以发现在while中声明的位置不受影响
//int main()
//{
//	int c = 0;
//	scanf("%d",&c);
//	while (c)
//	{
//		if (c == 3)
//		{
//			printf("hehe\n");
//			break;
//		}
//	}
//	return 0;
//}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值