#include<stdlib.h>
#include<stdio.h>
int 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<gess) {printf("small\n");sum++;}
else printf("Good! You use %d\n",sum);
}
getchar();
getchar();
}
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();
}}