20 minutes to Set program, small sense

Source: Internet
Author: User

1. Topics

Time limit 20 minutes to write the program "randomly produce 100 or less of the 30 arithmetic problem."

2. Ideas

The generation of random numbers requires the rand () function, which randomly generates arithmetic with the rand () function,%4.

3. Code

#include <iostream>

#include <cmath>

using namespace Std;

void Main ()

{

int A, b, c,i;

for (i = 1; I <=30; i++)

{

A = rand ()% 99;

b = rand ()% 99;

c = rand ()% 4;

if (c = = 1)

cout <<i<< "," << a << "+" << b << "=" << Endl;

if (c = = 2)

cout << i<< "," <<a << "-" << b << "=" << Endl;

if (c = = 3)

cout <<i<< "," << a << "*" << b << "=" << Endl;

if (c = = 0)

cout << i<< "," <<a << "/" << b << "=" << Endl;

}

}

4, 20 minutes not completed reason

The main idea is not clear enough, too anxious to write, and not the whole process of the idea, simple to say is where to write, write the writing will not go down, in addition to RAND () function familiarity is not enough, after a certain time to think of this function.

20 minutes to Set program, small sense

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.