15張大聰  

源代码

#include<stdio.h>

#include<stdlib.h>
#include<time.h>
main()
{
int a,b,op,os;

printf(" [天天练,Baby们来挑战吧!]\n");
aq1: printf("选择您想挑战的运算法则\n");
printf("1.加法 2.减法 3.乘法 4.除法\n");
scanf("%d",&op);
switch(op)
{
aq: case 1:
srand((unsigned)time(NULL));
a=rand()%100+1;b=rand()%100+1;
printf("题目为:%d + %d = ?\n\n",a,b);
printf("1.查看答案 2.做下一题\n");
scanf("%d",&os);
if(os==1)
{printf("%d + %d =%d\n\n\n",a,b,a+b);
goto aq1;
}
else
goto aq;
break;
at: case 2:a=rand()%100+1;b=rand()%100+1;
printf("题目为:%d - %d = ?\n\n",a,b);
printf("1.查看答案 2.做下一题\n");
scanf("%d",&os);
if(os==1)
{printf("%d - %d =%d\n\n\n",a,b,a-b);
goto aq1;
}
else
goto at;
break;
aq2: case 3:
a=rand()%100+1;b=rand()%100+1;
printf("题目为:%d * %d = ?\n\n",a,b);
printf("1.查看答案 2.做下一题\n");
scanf("%d",&os);
if(os==1)
{printf("%d * %d =%d\n\n\n",a,b,a*b);
goto aq1;
}
else
goto aq2;
aq3: case 4:
a=rand()%100+1;b=rand()%100+1;
printf("题目为:%d / %d = ?\n\n",a,b);
printf("1.查看答案 2.做下一题\n");
scanf("%d",&os);
if(os==1)
{printf("%d / %d =%d\n\n\n",a,b,a/b);
goto aq1;
}
else
goto aq3;
break;
}
}

截图

 

总结

做得有点仓促所以做得不是很好,除法方面小数跟负数都不能够处理,这方面没有考虑进去。

posted on 2015-03-26 17:59  15张奇聪  阅读(224)  评论(2编辑  收藏  举报