猜数字小游戏
来源:互联网 发布:win bash linux桌面 编辑:程序博客网 时间:2024/06/16 11:54
#include <stdio.h>#include <ctype.h>#include <time.h>#include <stdlib.h>int main(){ char input = 'y'; int limit = 2; long long getNum = 0LL; long long showNum; int i; clock_t now; int score = 0; srand(time(NULL)); do { showNum = 0LL; //输出字符串 for (i=0;i<limit;i++) { if(i==0) { showNum = 10*showNum + 1 + rand()%9; } else { showNum = 10*showNum + rand()%10; } } printf("%lld",showNum); //等待1秒后消除 now = clock(); for (; (clock()-now) < (CLOCKS_PER_SEC*2) ;) printf("\r"); for(i=0;i<limit;i++) { printf(" "); } printf("\r"); //接受用户输入并判断 printf("请重复输入之前的数字:\n"); scanf("%lld",&getNum); if (showNum == getNum) { printf("正确.\n"); score += 10*limit; limit++; input = 'y'; } else { printf("错误,游戏结束.\n"); printf("总得分:%d\n",score); limit = 2; score = 0; fflush(stdin); printf("是否继续(y/n):\n"); scanf("%c",&input); } } while(tolower(input)=='y'); }
0 0
- 猜数字小游戏
- 猜数字小游戏
- 猜数字小游戏(MiniGUI)
- 猜数字小游戏
- 猜数字小游戏
- Flex:猜数字小游戏
- c#猜数字小游戏
- 猜数字的小游戏~
- 猜数字 小游戏
- 猜数字的小游戏
- shell猜数字小游戏
- 猜数字小游戏
- 猜数字小游戏
- 猜数字小游戏 v1
- 猜数字小游戏 v3
- C#猜数字小游戏
- js猜数字小游戏
- Python 猜数字 小游戏
- PHP 函数
- java 网络请求
- Mac安装OpenCV下载ippicv_macosx_20141027.tgz失败解决方案
- EZ-USB固件框架的追踪研读之main函数3
- C语言数组参数与指针参数
- 猜数字小游戏
- 指向数组的指针和二维数组
- java 调用 powershell 遇到的 reader.readLine() 卡住问题
- 每隔一段时间获取一次gps信息
- Android基础之状态保存与恢复
- C语言实现md5校验
- 初识django
- This Android SDK requires Android Developer Toolkit version 23.0.0 or above
- BW系列之cube