![](https://iknow-base.cdn.bcebos.com/lxb/notice.png)
用C语言编写一个二位数加减法测验程序,要求:
,要求:1)系统自动出题,每题互不相同,加减法交替(假设答题者不知何为负数);2)参加运算的操作数在10到99之间;3)答题者对每道题有两次答题机会,程序自动判分,第一次...
,要求:
1) 系统自动出题,每题互不相同,加减法交替(假设答题者不知何为负数);
2) 参加运算的操作数在10到99之间;
3) 答题者对每道题有两次答题机会,程序自动判分,第一次答题正确给2分,第二次答题正确给1分;否则做下一题;
4) 答题者应能知道自己当前已经得了多少分;
5) 程序界面应尽可能方便答题者操作;
6) 满100分终止答题,并对答题情况有分析结论,比如正确率,等等. 展开
1) 系统自动出题,每题互不相同,加减法交替(假设答题者不知何为负数);
2) 参加运算的操作数在10到99之间;
3) 答题者对每道题有两次答题机会,程序自动判分,第一次答题正确给2分,第二次答题正确给1分;否则做下一题;
4) 答题者应能知道自己当前已经得了多少分;
5) 程序界面应尽可能方便答题者操作;
6) 满100分终止答题,并对答题情况有分析结论,比如正确率,等等. 展开
3个回答
展开全部
#include "stdio.h"
#include "stdlib.h"
void main()
{
int a,b,answer,t;
int score=0;
int i=0;
int total=0;
int correct=0;
while(score<100)
{
a=(rand()+10)%100;
b=(rand()+10)%100;
if((i++)%2)
{
printf("%d+%d=",a,b);
scanf("%d",&answer);
if(a+b==answer)
{
score+=2;
correct++;
}
else
{
printf("Again:");
scanf("%d",&answer);
if(a+b==answer)
{
score+=1;
correct++;
}
}
}
else
{
if(a<b)
{
t=a;
a=b;
b=t;
}
printf("%d-%d=",a,b);
scanf("%d",&answer);
if(a-b==answer)
{
score+=2;
correct++;
}
else
{
printf("Again:");
scanf("%d",&answer);
if(a-b==answer)
{
score+=1;
correct++;
}
}
}
printf("score:%d\n",score);
total++;
}
printf("Precition:%d%%\n",100*correct/total);
}
#include "stdlib.h"
void main()
{
int a,b,answer,t;
int score=0;
int i=0;
int total=0;
int correct=0;
while(score<100)
{
a=(rand()+10)%100;
b=(rand()+10)%100;
if((i++)%2)
{
printf("%d+%d=",a,b);
scanf("%d",&answer);
if(a+b==answer)
{
score+=2;
correct++;
}
else
{
printf("Again:");
scanf("%d",&answer);
if(a+b==answer)
{
score+=1;
correct++;
}
}
}
else
{
if(a<b)
{
t=a;
a=b;
b=t;
}
printf("%d-%d=",a,b);
scanf("%d",&answer);
if(a-b==answer)
{
score+=2;
correct++;
}
else
{
printf("Again:");
scanf("%d",&answer);
if(a-b==answer)
{
score+=1;
correct++;
}
}
}
printf("score:%d\n",score);
total++;
}
printf("Precition:%d%%\n",100*correct/total);
}
追问
还有没有其他的做法。谢谢了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询