教小学生学算术
#include
#include
#include
#include
int n;
void voice(void);
void welcome_text();
void c_text();
int gwjj();
int swjj();
int gwcc();
int swcc();
int szhh();
void graph()
{ clrscr();
textcolor(YELLOW);
gotoxy(10,10);
cprintf("*********************************************************");
gotoxy(10,11);
cprintf("*");
gotoxy(10,12);
cprintf("*");
gotoxy(10,13);
cprintf("*");
gotoxy(10,14);
cprintf("*");
gotoxy(10,15);
cprintf("*");
gotoxy(10,16);
cprintf("*");
gotoxy(10,17);
cprintf("*");
gotoxy(10,18);
cprintf("**********************************************************");
gotoxy(67,10);
cprintf("*");
gotoxy(67,11);
cprintf("*");
gotoxy(67,12);
cprintf("*");
gotoxy(67,13);
cprintf("*");
gotoxy(67,14);
cprintf("*");
gotoxy(67,15);
cprintf("*");
gotoxy(67,16);
cprintf("*");
gotoxy(67,17);
cprintf("*");
}
void choose()
{textcolor(RED);
gotoxy(25,11);
cprintf("欢迎来到小学生算算术系统");
textcolor(11);
gotoxy(35,12);
cprintf("MENU");
textcolor(WHITE);
gotoxy(11,13);
cprintf("各位加减(press 1)");
gotoxy(39,13);
cprintf("十位加减(press 2)");
gotoxy(11,15);
cprintf("个位乘除(press 3)");
gotoxy(39,15);
cprintf("十位乘除(press 4)");
gotoxy(27,17);
cprintf("四则混合 (press 5)");
}
void main()
{ int c,l1,l2,l3,l4,l5;
graph();
choose();
printf("\r\n\n\n\n");
scanf("%d",&c);
switch(c)
{case 1:clrscr();l1=gwjj();if(l1==0) break;
case 2:clrscr();l2=swjj();if(l2==0) break;
case 3:clrscr();l3=gwcc();if(l3==0) break;
case 4:clrscr();l4=swcc();if(l4==0) break;
case 5:clrscr();l5=szhh();if(l5==0) break;
}
graph();
choose();
}
int gwjj()
{ int k1,k2,k,t=0,f=0,p,v,l1,a;
welcome_text();
printf("你想要做多少个课题?\n");
scanf("%d",&n);
do
{for(p=0;p
k2=rand()%10;
if(rand()%2)
printf("%d+%d= ",k1,k2);
else
{if(k1
k2=-k2;
}
scanf("%d",&k);
if(k==k1+k2)
{t++;printf("非常好,你是正确的!\n");}
else
{f++;
printf("对不起,你的答案是错的,你能再次输入:");voice();
scanf("%d",&k);
if(k!=k1+k2)
{k=k1+k2;
printf("它的回答是:%d\n",k);
}
else
printf("现在你的回答是对的\n");
}
}
v=(t/n)*100;
if(v>=80)
{ c_text();
scanf("%d",&l1);
if(l1==1)return 1;
else return 0;
}
else
{printf("你应该再试一次吧,是吗?1 是,0 不\n");
scanf("%d",&l1);
if(l1==1)continue;
else
return 0;
}
}while(1);
}
int swjj()
{int k1,k2,k,t=0,f=0,v,p,l2,a;
welcome_text();
printf("你想要做多少个课题?\n");
scanf("%d",&n);
do
{ for(p=0;p
k2=rand()%100;
if(rand()%2)
printf("%d+%d= ",k1,k2);
else
{ if(k1
k2=-k2;
}
scanf("%d",&k);
if(k==k1+k2)
{t++;printf("非常好,你是正确的!\n"); }
else
{f++;
printf("对不起,你的答案是错的,你能再次输入:");voice();
scanf("%d",&k);
if(k!=k1+k2)
{k=k1+k2;
printf("它的答案是:%d\n",k);
}
else
printf("现在你是正确的!\n");
}
v=(t/n)*100;
if(v>=80)
{c_text();
scanf("%d",&l2);
if(l2==1)return 1;
else return 0;
}
else
{printf("你应该再试一次吧,是吗?1 是,0 不\n");
scanf("%d",&l2);
if(l2==1)continue;
else
return 0;
}
}
}while(1);
}
int gwcc()
{int k1,k2,k,t=0,f=0,v,p,l3,a=0;
welcome_text();
printf("你想要做多少个课题?\n");
scanf("%d",&n);
do
{for(p=0;p
k2=rand()%10;
if(rand()%2)
printf("%d*%d= ",k1,k2);
else
{k2=k2+1;
k1=k1*k2;
printf("%d/%d= ",k1,k2);
a=1;
}
scanf("%d",&k);
if(a==0)
{if(k==k1*k2)
{t++;printf("非常好,你是正确的!\n");}
else
{f++;
printf("对不起,你的答案是错的,你能再次输入:");
voice();
scanf("%d",&k);
if(k!=k1*k2)
{k=k1*k2;
printf("它的答案是:%d\n",k);
}
else
printf("现在你的回答是正确的!\n");
}
}
else
{if(k==k1/k2){t++;printf("非常好,你是正确的!\n");}
else
{ f++;
printf("对不起,你的答案是错的,你能再次输入:");
voice();
scanf("%d",&k);
if(k!=k1/k2)
{k=k1/k2;
printf("它的答案是:%d",k);
}
else
printf("现在你的回答是正确的!\n");
}
}
}
v=(t/n)*100;
if(v>=80)
{c_text();
scanf("%d",&l3);
if(l3==1) return 1;
else return 0;
}
else
{printf("你应该再试一次吧,是吗?1 是,0 不\n");
scanf("%d ",&l3);
if(l3==1)continue;
else
{return 0;}
}
}while(1);
}
int swcc()
{ int k1,k2,k,t=0,f=0,p,v,l4,a=0;
welcome_text();
printf("你应该再试一次吧,是吗?1 是,0 不\n?\n");
scanf("%d",&n);
do
{ for(p=0;p
k1=rand()%100;
k2=rand()%100;
if(rand()%2)
printf("%d*%d= ",k1,k2);
else
{k2=k2+1;
k1=k2*k1;
printf("%d/%d= ",k1,k2);
a=1;
}
scanf("%d",&k);
if(a==0)
{if(k==k1*k2)
{t++;printf("非常好,你是正确的!\n");}
else
{f++;
printf("对不起,你的答案是错的,你能再次输入:");
voice();
scanf("%d",&k);
if(k==k1*k2)
{k=k1*k2;
printf("它的答案是:%d",k);
}
else
printf("现在你的回答是正确的!\n");
}
}
else
{
if(k==k1/k2)
{t++;printf("True\n");}
else
{f++;printf("Wrong\n");voice();}
}
}
v=(t/n)*100;
if(v>=80)
{c_text();
scanf("%d",&l4);
if(l4==1) return 1;
else return 0;
}
else
{printf("你应该再试一次吧,是吗?1 是,0 不\n");
scanf("%d",&l4);
if(l4==1)continue;
else
return 0;
}
}while(1);
}
int szhh()
{ int k1,k2,t=0,f=0,p,v,k,x,l5;
printf("有多少个课题可以做?/n");
scanf("%d",&n);
do
{ for(p=0;p
k2=rand()%10;
if(rand()%2)
{printf("%d*%d-%d= ",k1,k2,k1);
scanf("&d",&k);
if(k==k1*k2-k1)
{t++;printf("非常好,你是正确的!\n"); }
else
{f++;
printf("对不起,你的答案是错的,你能再次输入:");
scanf("%d",&k);
if(k!=k1*k2-k1)
{x=k1*k2-k1;
printf("它的答案是:%d\n",x);
}
else
{printf("现在你的回答是正确的\n");}
}
}
else
{if(k1>k2)
{k2=k2+1;
k1=k2*k1;
printf("%d+%d/%d= ",k2,k1,k2);
scanf("%d",&k);
if(k==k2+k1/k2)
{t++;printf("非常好,你是正确的!\n");}
else
{f++;
printf("对不起,你的答案是错的,你能再次输入:");
scanf("%d",&k);
if(k!=k2+k1/k2)
{x=k2+k1/k2;
printf("the answer is:%d\n",x);
}
else
{printf("现在这个时候你的回答是正确的\n"); }
}
}
else
{k1=k1+1;
k2=k1*k2;
printf("%d-%d/%d= ",k2,k2,k1);
scanf("%d",&k);
if(k==k2-k2/k1)
{t++;printf("非常好,你是正确的!\n");}
else
{f++;
printf("对不起,你的答案是错的,你能再次输入:");
scanf("%d",&k);
if(k!=k2-k2/k1)
{x=k2-k2/k1;
printf("The answer is:%d\n",x);
}
else
{printf("现在你的回答是正确的\n");}
}
}
}
}
v=(t/n)*100;
if(v>=80)
{c_text();
scanf("%d",&l5);
if(l5==1) return 1;
else return 0;
}
else
{printf("你应该再试一次吧,是吗?1 是,0 不\n");
scanf("%d ",&l5);
if(l5==1)continue;
else
{return 0;}
}
}while(1);
}
void voice()
{sound(500);
delay(100000);
nosound();
}
void welcome_text()
{textcolor(RED);
gotoxy(2,2);
cprintf("欢迎到这:\r\n");
}
void c_text()
{textcolor(RED);
cprintf("祝贺你,走到下一阶段?1 是,0 不\n");
}