C语言设计小学算术运算测试。

2024-12-19 01:23:48
推荐回答(3个)
回答1:

Please input question total:4
78 - 70 = 8
Right!
59 - 34 = 25
Right!
82 + 92 = 11
Wrongthe answer is [174].
52 + 53 = 105
Right!
there are 4 Questions,Right 3,Wrong 1.
Score is 75.0.
Press any key to continue

#include
#include
#include

main()
{
int count,countRc,cal1,cal2,answer,inputas,score=0;
srand((unsigned)time(NULL));
printf("Please input question total:");
scanf("%d",&count);
countRc = count;
while (count-->0)
{
cal1= rand()%98+1;
cal2= rand()%98+1;
if (cal1>cal2)
{
answer = cal1 - cal2;
printf("%d - %d = ",cal1,cal2);
}else
{
answer = cal1 + cal2;
printf("%d + %d = ",cal1,cal2);
}
scanf("%d",&inputas);
if (answer==inputas)
{
printf("Right!\n");
score++;
}else
{
printf("Wrong!\b");
printf("the answer is [%d].\007\n",answer);
}
}
printf("there are %d Questions,Right %d,Wrong %d.\nScore is %2.1f.\n",
countRc,score,countRc-score,(float)score/countRc*100);
}

回答2:

要有 用户界面 用C 编起来 很麻烦。要是 没界面,小学生 不会 操作

回答3:

好麻烦的……