标签:猜数字游戏
#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; }
标签:猜数字游戏
原文地址:http://baixu.blog.51cto.com/10798719/1708060