如何编写一个C语言程序,让计算机自动出四则运算计算题,要求自动出0-10之间的四则运算题,并批改结果?

问题描述:

如何编写一个C语言程序,让计算机自动出四则运算计算题,要求自动出0-10之间的四则运算题,并批改结果?

少年,写好了,给你参考一下.还可以更复杂.
#include
#include
#include
#define N 10
int Test()
{
int num = 0;
int answer = 0;
int result = 0;
int m = 0;
int n = 0;
char op = 0;
int count = N;
while ( count-- )
{
m = rand() % 10;
n = rand() % 10;
op = rand() % 4;
switch ( op )
{
case 0:
op = '+';
answer = m+n;
break;
case 1:
op = '-';
answer = m-n;
break;
case 2:
op = '*';
answer = m*n;
break;
case 3:
n++;
op = '/';
answer = m/n;
break;
default:
break;
}
printf("\n题目:");
printf("%d%c%d=?\n",m,op,n);
printf("请输入答案:");
scanf("%d",&result);
if ( answer == result )
num++;
}
return num;
}
int main()
{
srand( time(NULL) );
printf("开始做题:\n");
printf("答题结束,你总共答对%d道题目.\n",Test());
return 0;
}