Arithmetic (2) design ideas

Source: Internet
Author: User

Requirements:
1 topics to avoid duplication
2 Customizable (Qty/print mode)
3 can control the following parameters: whether there is a multiplication method, whether there are parentheses, the range of values, plus or minus a negative number, division has a zero, whether to support fractions (true score false score), whether to support decimals (accurate to how many bits), the interval of each line in the printing.

Solution Ideas:
1. Avoid duplication: Random number function + system time generates every random number, each one is stored, each generation of the equation is checked once, if the repetition is re-generated. Use a function when checking the equation.
2. Customizable: Use for loop to control the quantity, the specific quantity has the user input, each line outputs several formulas by the user input, and stores.
3. Control parameters: At the beginning of the program design interface used by the user input requirements, will be required to store. The set of parameters is stored uniformly together.
(1) Whether there is a multiplication method: randomly generated operation symbols, subtraction storage, cs[0] Storage
(2) Whether there are parentheses: stored with a[1], 1 with parentheses, and 0 o'clock without parentheses.
(3) Numerical range: with a[2] storage, with A+rand ()%b, to achieve.
(4) The addition and subtraction of negative numbers: with A[3] storage, using the IF statement to determine the storage requirements.
(5) Division has an empty number: with A[4] storage, for 1 o'clock hours, the number of 0 o'clock. Use the function to check whether each of the equations is a surplus.
(6) Whether to support decimals (accurate to how many bits): stored with a[5], 0 o'clock no decimal, n time, is n decimal place.
(7) The interval of each line in the printing: storage with a[6], 0 o'clock no interval, n, Interval n rows.

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.