1#include"stdio.h"2#include"math.h"3#include"stdlib.h"4#include"time.h"5 intMain ()6 {7 Srand (Time (NULL));8 inta,b,c,i;9 Charx[5];Ten for(i=0;i< -; i++) One { AA=rand ()% -; -B=rand ()% -; -C=rand ()%4; the Switch(c) - { - Case 0: -printf"%d+%d=\t\t", A, b); + Break; - Case 1: + if(a>=b) Aprintf"%d-%d=\t\t", A, b); at Else -printf"%d-%d=\t\t", b,a); - Break; - Case 2: -printf"%d*%d=\t\t", A, b); - Break; in Case 3: - if(b==0) toprintf"%d/%d=\t\t", b,a); + Else -printf"%d/%d=\t\t", A, b); the Break; * } $ Panax Notoginseng } -printf"\ n"); the return 0; +}
View Code
Design ideas:
1. Randomly generate 0-100 of the data, so the use of the random function, followed by addition, subtraction, multiplication, and besides is also random, so the use of random functions, using 0,1,2,3 to represent
2. Also note that the result of subtraction can not be negative, so the judgment, if A<b, is B-a, and Vice-B;
Reasons for not completing the class:
1. The use of random functions to forget the method;
2. A long time without C language programming, unfamiliar;
Software engineering with the work--randomly generated 30 to arithmetic (C language)