#include <stdio.h> #include <stdlib.h> #include <time.h>int i=0,j=0;void Jia () {int A,b,m;srand ( NULL)); A=1+rand ()%100; B=1+rand ()%100; printf ("%d\n", a); printf ("%d\n", b); printf ("a+b=?\n");p rintf ("Please enter the result of the operation \ n"); scanf ("%d", &m), if (m==a+b) {printf ("Congratulations on your correct answer \ n"); i++;} else{printf ("You have the wrong answer \ n"); J + +;}} void Jian () {int A,b,m;srand (time (NULL)); A=1+rand ()%100; B=1+rand ()%100;if (a<b) {int t=0;t=a;a=b;b=t;} printf ("%d\n", a); printf ("%d\n", b); printf ("a-b=?\n");p rintf ("Please enter the result of the operation \ n"); scanf ("%d", &m), if (m==a-b) {printf ("Congratulations on your correct answer \ n"); i++;} else{printf ("You have the wrong answer \ n"); J + +;}} void Cheng () {int A,b,m;srand (time (NULL)); A=1+rand ()%20; B=1+rand ()%20; printf ("%d\n", a); printf ("%d\n", b); printf ("a*b=?\n");p rintf ("Please enter the result of the operation \ n"); scanf ("%d", &m), if (m==a*b) {printf ("Congratulations on your correct answer \ n"); i++;} else{printf ("You have the wrong answer \ n"); j + +;}} void Chu () {int A,b,m;srand (time (NULL)); A=1+rand ()%100; B=1+rand ()%100;if (b==0) {B=1+rand ()%100;} IF (a<b) {int t=0;t=a;a=b;b=t;} while (a%b!=0) {A=1+rand ()%100; B=1+rand ()%100;} printf ("%d\n", a); printf ("%d\n", b); printf ("a/b=?\n");p rintf ("Please enter the result of the operation \ n"); scanf ("%d", &m), if (m==a/b) {printf ("Congratulations on your correct answer \ n"); i++;} else{printf ("You have the wrong answer \ n"); j + +;}}
int main () {int M,n=0;while (1) {printf ("1. addition operation \ n");p rintf ("2. Subtraction operation \ n");p rintf ("3. multiplication \ n");p rintf ("4. Division operation \ n");p rintf ("Please select"); scanf ("%d", &m); switch (m) {case 1:jia (); break;case 2:jian (); break;case 3:cheng (); break;case 4:chu (); break;} printf ("5. Please re-select \ n");p rintf ("6. End \ n"); scanf ("%d", &n); if (n==6) break;} printf ("You answer the total number%d and the correct number of%d\n", i+j,i); return 0;}
The above is the test process.
Software Engineering Second Job