- #include"stdio.h"
- #include"time.h"
- #include"stdlib.h"
- void play_game()
- {
- int fog = 0;
- int random = 0;
- random=rand()%101;
- while(1)
- {
- printf("请输入一个数:");
- scanf("%d",&fog);
- if(random==fog)
- {
- printf("恭喜你,答对了\n");
- break;
- }
- else if (fog>random)
- {
- printf("你输入的大了\n");
- }
- else
- {
- printf("你输入的小了\n");
- }
- }
- }
- int main()
- {
- int input;
- srand((unsigned )time(NULL));
- do
- {
- menu();
- printf("请输入你的选择:");
- scanf("%d",&input);
- switch(1)
- {
- case 1:
- play_game();
- break;
- case 0:
- exit(EXIT_SUCCESS);
- default:
- printf("error");
- break;
- }
- }while(input);
- system("pause");
- return 0;
- }
c语言猜数字小游戏
最新推荐文章于 2024-02-08 09:45:27 发布