Home > Back-end >  Consult, what's the problem with this program?
Consult, what's the problem with this program?

Time:09-27

#include
#include
#include
The main ()
{
Int I, op, answer, magic1 magic2, counter, flag, score;
Float accuracy;
Counter=0;
for (i=1; i<=10; I++)
{
Srand (time (NULL));
Magic1=rand () % 10 + 1;
Magic2=rand () % 10 + 1;
Op=rand () % 4 + 1;
Flag=0;
The switch (op)
{
Case 1:
{
Printf (" % d + % d=? The \ n ", magic1, magic2);
The scanf (" % d, & amp; Answer ");
If (answer==magic1 + magic2)
{
flag=1;
Counter++;
}
}
Case 2:
{
Printf (" % d, % d=? The \ n ", magic1, magic2);
The scanf (" % d, & amp; Answer ");
If (answer==magic1 - magic2)
{
flag=1;
Counter++;
}
}
Case 3:
{
Printf (" % d % d *=? The \ n ", magic1, magic2);
The scanf (" % d ", & amp; Answer);
If (answer==magic1 * magic2)
{
flag=1;
Counter++;
}
}
Case 4:
{
Printf (" % d/d=%? The \ n ", magic1, magic2);
The scanf (" % d, & amp; Answer ");
If (answer==magic1/magic2)
{
flag=1;
Counter++;
}
}
}
If (flag)
{
Printf (" Right! \n");
}
The else
{
Printf (" Wrong! \n");
}
}
* 10 score=counter;
Accuracy=counter/10.0 * 100;
Printf (" % d, % 2 f \ n ", score, accuracy);
}

CodePudding user response:

Roughly, the back of the case didn't break,