C语言课程设计报告-猜数游戏|c语言程序代码编程小程序设计|c语言课程设计报告课程案例
#include#includeint dif_1();int dif_2();void menu_1();int menu_in();
int dif_1(){int dif_1;dif_1=random(10);return dif_1;}
int dif_2(){int dif_2;dif_2=random(100);return dif_2;}
void menu_1(){int i;clrscr();for(i=0;i<8;i++) printf("\n");printf(" Difficuty Choose\n");printf("\n\n");printf(" 1--Between 1 and 10\n\n");printf(" 2--Between 1 and 100\n\n");printf(" 3--Exit\n\n");
}int menu_in(){int choose;printf(" Choose:");scanf("%d",&choose);return choose;}
void test(int gess){int num=-1,sum=0;while(num!=gess){printf("Please input number:");scanf("%d",&num);if(num>gess) {printf("high\n");sum++;}else if(num}void error(){printf("Choose error!");getchar();getchar();}main(){int choose;
menu_1();choose=menu_in();switch(choose){case 1: test(dif_1());break;case 2: test(dif_2());break;case 3: exit(0);break;default: error();}}