#include"stdio.h"#include"stdlib.h"#include"time.h"Main () {inta,b,c,x,d,f=0, g=0; Srand ((unsigned) time (NULL)); A=rand ()% ++1; b=rand ()% ++1; printf ("Please select the addition operation of the title \n1.1-1000 the subtraction operation of the \n2.1-1000 \n3.1-1000 the multiplication operation \n4.1-1000 the division operation \n5. Exit answer \ n"); scanf ("%d",&x); System ("CLS"); while(g<=Ten) { if(x==1) {D=a+b; printf ("%d+%d=", A, b); } Else if(x==2) {D=a-b; printf ("%d-%d=", A, b); } Else if(x==3) {D=a*b; printf ("%d*%d=", A, b); } Else if(x==4) {D=a/b; printf ("%d/%d=", A, b); } Else{printf ("Press any key to exit! "); Break; } scanf ("%d",&c); if(c==d) {f=f+Ten; printf ("Congratulations, that's correct! Your score is%d minutes \ n", F); } Else{f=f-Ten; printf ("Sorry, the answer is wrong! Your score is%d minutes \ n", F); } g++; }}
These two days do a lot of random function usage (below is a quiz experiment).