#include<stdio.h> #include <time.h> #include<stdlib.h> void print() { printf("**************************\n"); printf("*******1. start ********\n"); printf("*******0. exit ********\n"); printf("**************************\n"); } void play(int val) { int select; printf("请选择:>\n"); scanf("%d",&select); switch(select) { int n; case 1: while(1) { printf("亲,请输入0-100之间的数:>\n"); scanf("%d",&n); if( n > val ) { printf("不好意思,您猜大了!\n"); } else if( n < val ) { printf("不好意思,您猜小了!\n"); } else { printf("恭喜您,您猜对了!\n"); break; } } break; default: printf("退出系统!\n"); break; } } int main() { int m; srand(time(NULL)); m=rand()%100; while(m) { print(); play(m); } return 0; }
猜数字游戏
原创
©著作权归作者所有:来自51CTO博客作者xupresent的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:局部变量,全局变量的应用
下一篇:可变参数列表
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
猜数字小程序源码安卓
-
摘要 数字签名 数字证书 加密 国密 OpenSSL OpenSSH
摘要 数字签名 数字证书 国密 对称加密 非对称加密 openssl工具 openssh
加密算法 数字签名 数字证书 国密 对称加密