#include
#include
# define N 10//10 topic
Int main ()
{
Int I, right=0, the error=0;
Int a, b, op, the result, the input;
Char ops.
Srand (time (NULL));
Printf (" please calculate the following arithmetic results: \ n ");
for(i=1; i<=N; I++)
{
Printf (" % 2 d: ", I);
A=rand () % 10; The two Numbers//topic request within 10 + - *
B=rand () % 10;
Op=rand () % 3;
The switch (op)
{
Case 0: ops='+'; Result=a + b; break;
Case 1: ops='-'; If (a> Result=a - b=b);
The else result=b - a; break;
Case 2: ops='*'; Result=a * b; break;
Case 3: ops='/'; Result=a/b; break;
Default: break;
}
If (aPrintf (" % d % d % c=", b, ops, a);
The else printf (" % d % % d="c, a, ops, b);
The scanf (" % d ", & amp; Input);
If (result==input)
{
Printf (" the answer right!!! \n");
Right=right + 1;
}
The else
{
Printf (" the answer wrong! \n");
Error=error + 1;
}
}
Printf (" practice results: what do you do on the % d problem, wrong % d problem, \ n ", right, and the error).
return 0;
}
CodePudding user response:
Is anyone here??????CodePudding user response:
% 3 is not 3,CodePudding user response:
%CodePudding user response:
B=1 + rand () % 9;//avoid 0 as the denominator