四则运算的在线答题(判断对错,记录错题)

个人项目3:可以在之前基础上实现在线答题;

答题结束后可以判断对错;

可以将错题保存起来;

程序:

#include
#include
#include
void boom()
{
float x,y;
int a,b;
int first_num,second_num,third_num,fourth_num;
srand(time(NULL));
int n;
float k;
float d;
float daan[100];
int zq=0;
int cw=0;
cout<<"所需题数"<cin>>n;
for(int i=0;i {
a=rand()%4;
first_num=rand()%10;
second_num=rand()%10;
third_num=rand()%10;
fourth_num=rand()%10;
if (second_num==1)
{
x=(float)first_num;
}
else if(first_num>second_num)
{
b=first_num;
first_num=second_num;
second_num=b;
}
x=(float)first_num/second_num;
if (fourth_num==1)
{
y=(float)third_num;
}
else if(third_num>fourth_num)
{
b=third_num;
third_num=fourth_num;
fourth_num=b;
}
y=(float)third_num/fourth_num;
a=rand()%4;
switch(a)
{
case 0:
cout< daan[i+1]=x+y;
break;
case 1:
cout< daan[i+1]=x-y;
break;
case 2:
cout< daan[i+1]=x*y;
break;
case 3:
if(y!=0)
{
cout< }
else
{
i=i-1;
}
daan[i+1]=(float)x/y;
break;
}
if((i+1)%3==0)
{
for(int c=0;c<=1;c++)
{
cout< }
}
if((i+1)==n)
{
cout< }
}
for(i=1;i<=n;i++)
{
cout<<"请答题:"< cout< cin>>d;
if(d==daan[i])
{
cout<<"回答正确!"< cout< zq=zq+1;
}
else
{
cout<<"回答错误,正确答案为:"<<" "<cout<cw=cw+1;
}
}
k=(float)zq/n;
cout<<"答对数为:"<<" "<cout<<"答错数为:"<<" "<cout<<"正确率为:"<<" "<}
int main()
{
boom();
main();
return 0;
}

运行结果:

四则运算的在线答题(判断对错,记录错题)_第1张图片

出现的问题:

不知如何将错题保存,以及以什么形式保存。

转载于:https://www.cnblogs.com/amnavov/p/9885756.html

你可能感兴趣的:(四则运算的在线答题(判断对错,记录错题))