Current location - Training Enrollment Network - Mathematics courses - C++ source code of random problems in primary school mathematics
C++ source code of random problems in primary school mathematics
Here, the running confirmation has been compiled:

# include & ltiostream & gt

# include & ltcstdlib & gt

Use namespace std

Invalid Fu Hao (integer x)

{

if(x = = 0)printf("+");

if(x = = 1)printf("-");

if(x = = 2)printf(" * ");

}

int main()

{

int a,b,t,p,flag

Int score = 0;

int n,I;

Cycle:

System ("CLS");

Cout & lt& lt "How many questions do you want to answer?" & lt& ltendl

CIN & gt; & gtn;

Cout & lt& lt "Start the test!" & lt& ltendl

for(I = 0; I & ltn;; i++)

{

Cout & lt& lt "first"

a = rand()% 10;

b = rand()% 10;

If (a<b)

flag = rand()% 3;

cout & lt& lta;

Fu Hao (national flag);

cout & lt& ltb & lt& lt" = ";

CIN & gt; & gtt;

If (flag ==0)

{

If (t==a+b)

Else cout & lt& lt "Wrong answer! The correct answer is: "

}

if(flag== 1)

{

If (t==a-b)

Else cout & lt& lt "Wrong answer! The correct answer is: "

}

if(flag==2)

{

If (t==a*b)

Else cout & lt& lt "Wrong answer! The correct answer is: "

}

}

Cout & lt& lt "The total number of correct questions is:"

Cout & lt& lt "Do you want to continue? 1. Continue 2. Quit "

CIN & gt; & gtt;

If(t== 1) goes to the loop;

Else cout & lt& lt "Welcome! Goodbye! " & lt& ltendl

System ("suspended");

Returns1;

}