Software Engineering Personal Assignment 01

Source: Internet
Author: User

Design ideas:

1. Generate 4 random numbers with random number generation function

2. Intermediate random number processing, in addition to 4, 0,1,2,3 respectively represents subtraction. The last random number is 2, 0 is the integer, and 1 is the false fraction.

3. When generating division, the divisor is not 0.

4. Random topic generation, Cycle 30 topics

5. Output

SOURCE program code:

#include <iostream>using namespacestd; #include<time.h>structyunsuan{intFuhao; intOne ; intboth ; int Select;};intMain () {Yunsuan num[ -]; Srand ((int) Time (NULL)); inti;  for(i=0;i< -; i++) {Num[i].one= rand ()% -; Num[i].two= rand ()% -; Num[i].fuhao= rand ()%4; Num[i].Select= rand ()%2; if(num[i].fuhao==3)        {            if(Num[i].two = =0&&num[i].one <num[i].two) {i=i-1; }        }    }     for(i=0;i< -; i++)    {        if(Num[i].Select==0)        {            if(num[i].fuhao==0) {cout<< Num[i].one <<" + "<< Num[i].two <<" = "<<Endl; }            if(num[i].fuhao==1) {cout<< Num[i].one <<" - "<< Num[i].two <<" = "<<Endl; }            if(num[i].fuhao==2) {cout<< Num[i].one <<" * "<< num[i].two<<" = "<<Endl; }            if(num[i].fuhao==3) {cout<< Num[i].one <<" / "<< num[i].two<<" = "<<Endl; }        }        Else        {            intNUM1 = rand ()% -+1; intnum2 = num[i].one+1; intnum3 = rand ()% -+1; intNUM4 = num[i].two+1; if(num[i].fuhao==0) {cout<< NUM1 <<"/"<< num2 <<" + "<< num3 <<"/"<< num4 <<" = "<<Endl; }            if(num[i].fuhao==1) {cout<< NUM1 <<"/"<< num2 <<" + "<< num3 <<"/"<< num4 <<" = "<<Endl; }            if(num[i].fuhao==2) {cout<<"("<< NUM1 <<"/"<< num2 <<") * ("&LT;&LT;NUM3 <<"/"<< num4 <<") = "<<Endl; }            if(num[i].fuhao==3) {cout<<"("<< NUM1 <<"/"<< num2 <<") /("&LT;&LT;NUM3 <<"/"<< num4 <<") = "<<Endl; }        }    }}

Operation Result:

Reasons why the class was not completed on time:

Software Engineering Personal Assignment 01

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.