"Arithmetic 2 design Ideas"

Source: Internet
Author: User
Tags case statement

Arithmetic 2 design ideas;

(1) First, using the switch statement, let the user select the number of operations to be performed in the range, and then the individual case statements to invoke the corresponding random function to generate a number ();

(2) As to the number of topics to be used to define the macro, let the user input the number of the calculation of the problem;

(3) The resulting random number defined by the beginning defines the integer type; If the user does not have a specific requirement, the default is to execute the case statement: the user chooses the operation method to be performed, that is, the subtraction four method is a single operation, wherein the addition and subtraction function to add a judgment statement, If there is a negative number in the generated random numbers, then add a parenthesis and then continue to output the corresponding form; If the division operation is to determine whether the number of 0, if all is 0, skip this logarithm do not output, if only one is 0, then let 0 as dividend, and then output in the corresponding format can be;

(4) As for the printed form, can also be printed according to user needs, so that users enter the number of questions per row, using the definition of macro definition can be;

(5) If there is a special demand, the user according to their own needs in accordance with the system's prompt step-down execution; If you need to add the multiplication method, in the corresponding Case statement subtraction four kinds of operations generated under the problem of integration in a piece can be; For division there is no number, Users are also in accordance with their own needs in accordance with the system's prompt step-by-step implementation, allow the number of the division, it is not necessary to modify the function, if not allow it must be judged as a division operation of the two number is a multiple relationship, only if the premise of satisfying the sub-condition can continue to output; If not supported, then the system default two data is the form of integral type to calculate, if the support is to take into account the resulting data type to be converted to double, but the corresponding problem can be output;

(6) As to whether the randomly generated topics are duplicated, then add a judgment statement separately under each case statement to judge the situation of the reuse of random numbers used in the case of various operation methods.

"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.