Arithmetic 2 design ideas

Source: Internet
Author: User

1. Avoid duplication of topics:

Store two random numbers, operators, and calculation results for each random arithmetic question in a different array,

In the next question, compare the results of the calculation is the same,

If the same re-comparison operator is the same,

to avoid duplication;

2. Custom Quantity, printing method:

Add two variables and use a For loop to control;

3. using Rand to generate 0~3 to control the operator, just let it produce 0~1, The multiplication method can be removed;

The range of values can also be controlled by Rand;

Use (rand ()%2?-1:1) * (random number) to generate positive and negative numbers;

After generating two random numbers, the remainder is calculated, if the residue is 0, the output operation, if the remainder is not 0, can be skipped;

Arithmetic 2 design ideas

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.