#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
srand(time(0));
printf("输入出题个数,以0结束。\n");
int n, cj = 0, a, b, c, jg;
scanf("%d", &n);
while (n)
{
for (int i = 0; i < n; i++)
{
a = rand() % 90 + 9;
b = rand() % 90 + 9;
c = rand() % 4 + 1;
switch (c)
{
case 1:
printf("%2d + %2d=", a, b);
scanf("%d", &jg);
if (jg == a + b)cj++;
break;
case 2:
printf("%2d - %2d=", a, b);
scanf("%d", &jg);
if (jg == a - b)cj++;
break;
case 3:
printf("%2d * %2d=", a, b);
scanf("%d", &jg);
if (jg == a * b)cj++;
break;
case 4:
printf("%2d / %2d=", a, b);
scanf("%d", &jg);
if (jg == a / b)cj++;
break;
}
printf("\n");
}
switch (cj * 100 / n)
{
case 90:
case 100:
printf("正确率%6.2f%%优秀\n", cj * 100*1.0 / n);
break;
case 70:
case 80:
printf("正确率%6.2f%%良好\n", cj * 100 *1.0/ n);
break;
case 50:
case 60:
printf("正确率%6.2f%%不错\n", cj * 100 *1.0/ n);
break;
default :
printf("正确率%6.2f%%还须努力\n", cj * 100*1.0 / n);
break;
}
cj=0;
printf("输入出题个数,以0结束.\n");
scanf("%d", &n);
}
return 0;
}只能进行加减乘除运算
[此贴子已经被作者于2018-5-21 17:17编辑过]