Software engineering with the work--randomly generated 30 to arithmetic (C language)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.