本文实例为大家分享了C语言实现随机出题测试计分的具体代码,供大家参考,具体内容如下
#include
#include
#include
int test();
int checknum(int a, int b);
int checkresult(int x);
int a = -1, b, c, x;
static int k = 0, grade;
void main() {
printf("请作答下列十道题,回车键开始开始作答!!!");
getchar();
do {
int i = test();
if (i == -1) {
break;
}
else if (checkresult(i) == 0) {
a = -1;
}
} while (k);
getchar(); getchar(); getchar();
}
int test() {
srand((unsigned int)time(NULL));
while (checknum(a, b) == 0)
{
a = rand() % 51;
b = rand() % 51;
c = rand() % 2;
}
k++;
if (k =