写了一个口算题卡的出题程序,编译没问题,但运行时出现Process exited after 7.745 seconds with return value 3221225477,麻烦帮忙看一眼
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define random(x) (rand()%x)
int main() { //出题
int a, b, c, d = 0, e = 0, i, xs = 1, t = 0, h = 0, j = 0;
int a1[50], aa[50], b1[10], bb[10];
double lv, f = 0, ta, td, junzhi = 0, rate[100];
char y, l;
srand((int)time(0));
clock_t start, end;
start = clock();
printf("答题开始时将会计时,请每次输入答案后按回车进行下一题的解答,");
printf("如果答题出现错误会重复该题,直到做对为止才会进入下一题,");
printf("每次共出15道口算题,祝您取得优异成绩。");
printf("请输入”y“进行答题\n");
while ((y = getchar()) == 'y') {//出题的循环
if (h == 0)
printf("现在,答题开始!\n");
for (i = 0; i < 10; i++) {//四则运算的出题
a = rand() % 20;
b = rand() % 20;
if (a >= b) {
while (1) {//减法题,同时如果计算错误将会重复本题直到计算正确
a1[i] = a - b;
printf("%d-%d=", a, b);
scanf("%d", &aa[i]);
if (a1[i] == aa[i]) {
t++;
break;
} else
f++;
}
}
else {
while (1) {//加法题,重复同上
a1[i] = b + a;
printf("%d+%d=", a, b);
scanf("%d", &aa[i]);
if (a1[i] == aa[i]) {
t++;
break;
} else
f++;
}
}
d++;
if (d % 2 == 0) {//乘除法题,循环同上
if (a % b == 0 || b % a == 0) {
if (a > b) {
while (1) {
b1[e] = a / b;
printf("%d/%d=", a, b);
scanf("%d", &bb[e]);
if (b1[e] == bb[e]) {
t++;
break;
} else
f++;
}
}
else {
while (1) {
b1[e] = b / a;
printf("%d/%d=", b, a);
scanf("%d", &bb[e]);
if (b1[e] == bb[e]) {
t++;
break;
} else
f++;
}
}
}
else {
if (a > 10) {
if (b > 10) {
a = a - 10;
b = b - 10;
} else
a = a - 10;
} else {
if (b > 10)
b = b - 10;
}
while (1) {
b1[e] = a * b;
printf("%d*%d=", a, b);
scanf("%d", &bb[e]);
if (b1[e] == bb[e]) {
t++;
break;
} else
f++;
}
}
e++;
}
}
end = clock();
printf("您本次一共用时%.1f秒\n", (double)(end - start) / CLOCKS_PER_SEC);
d = 0;
e = 0;
lv = t / (t + f);
printf("正确题数为%d\n", t);
printf("错误题数为%d\n", (int)f);
rate[j] = lv;
printf("本次正确率为%.1lf%%", lv * 100);
printf("请问您是否继续?\n");
printf("继续请输入“y”,退出请输入“n”\n");
getchar();
t = 0;
f = 0;
end = 0;
start = 0;
j++;
}
ta = rate[0];
td = rate[0];
for (i = 0; i < j; i++) {//比较多次正确率
if (rate[i] > ta)
ta = rate[i];
if (rate[i] < td)
td = rate[i];
}
for (i = 0; i < j; i++) {
junzhi += rate[i];
}
junzhi = junzhi / j;
printf("您一共测试了%d次口算\n", j);
printf("您正确率最高时为%.1f%%\n", ta * 100);
printf("您正确率最低时为%.1f%%\n", td * 100);
printf("您平均正确率为%.1lf%%\n", junzhi * 100);
printf("相信您的口算技巧会越来越好。\n");
}