This time I added a true fractional operation based on the last arithmetic, and changed the arithmetic code on the basis of the previous
The code is as follows:
#include <stdio.h>#include<Windows.h>#include<time.h>voidMain () {intA, B, C, d,i,m,n; floatp, q; Srand (Unsigned (Time (NULL))); for(i =0; I < -; i++) {a= rand ()% -; b= rand ()% -; C= rand ()%5; Switch(c) { Case 0: printf ("%d +%d =\n", A, b); Break; Case 1:if(A <b) {d=A; A=b; b=D; } printf ("%d-%d =\n", A, b); Break; Case 2:p rintf ("%d *%d =\n", A, b); Break; Case 3: while(b = =0) {b= rand ()% -; } printf ("%d/%d =\n", A, b); Break; Case 4: A= rand ()% -; b= rand ()% -; M= rand ()% -; N= rand ()% -; C= rand ()%4 ; while(b = =0) {b= rand ()% -; } while(n = =0) {n= rand ()% -; } if(A >b) {d=A; A=b; b=D; } if(M >N) {d=m; M=N; N=D; } Switch(c) { Case 0:p rintf ("%d/%d +%d/%d =\n", A, B, M, n); Break; Case 1: P= (float) A/(float) b; Q= (float) m/(float) n; if(P <q) {d=A; A=m; M=D; D=b; b=N; N=D; } printf ("%d/%d-%d/%d =\n", A,b,m,n); Break; Case 2:p rintf ("%d/%d *%d/%d =\n", A, B, M, n); Break; Case 3: A= rand ()% -; b= rand ()% -; M= rand ()% -; N= rand ()% -; C= rand ()%4; while(M = =0) {m= rand ()% -; } printf ("%d/%d/%d/%d =\n", A, B, M, n); Break; }}} System ("Pause"); }
The results of the operation are as follows:
This experiment is a good learning experience, their own long a lot of ability, there is not a small receipt, their own course to learn more hard, day up, and hope that they can learn this course, their computer has been relatively unfamiliar, I hope this exercise can strengthen their knowledge of the computer, At the same time improve their ability to strengthen their own
Design arithmetic to include true fractions in the second-grade primary school operation