150313 that poor two-pillar classmate

Source: Internet
Author: User
Tags repetition

Today's introduction to Software engineering class, the teacher has a problem:

Poor two pillars classmate, the teacher again on his automatic question system put forward a new request:

    1. Avoid duplication of topics
    2. can be customized (quantity, printing method);
    3. The following parameters can be controlled: whether there is a multiplication method, a range of values, plus or minus a negative number, division has a zero, whether the support score (true score, false score);

I've thought of two workarounds:

I. Using the database:

    1. Avoid duplication: random numbers and symbols generate input databases, generate MD5, database queries (Select Distinct MD5, first integer, symbol, second integer from the list of topics).
    2. Customize: Input box, enter the number of questions. The printing method can be used with [x + + if (x==?) Cout<<endl;] and can be exported to Word or Excel or txt
    3. Query plus conditions when querying from a database. For example: SELECT * from topic table where symbol = ' * ' SELECT * from topic table where second integer >0 etc.
    4. Fractional problem: When a random number is generated, the constraint two times the size of the random number to control the true and false fraction, forming a similar first integer/second integer. The database data type can be used for varchar to hold the entire score.

Two. Do not use the database:

    1. Avoid repetition: Save the generated topic as a string in the array. Each time a topic is generated, it is compared to each element in the array, and the repetition skips the cycle.
    2. Customization: Enter the number of topics, and print the same way, using [x + + if (x==?) Cout<<endl;]
    3. The multiplication method, which extracts the symbols of each topic at the time of printing, is compared. Other similar.
    4. Fractional problem: When a random number is generated, the constraint two times the size of the random number to control the true and false fraction, forming a similar first integer/second integer.

Personal bias Database solution, the next class to build a table, feasible. Just completely put the algorithm to realize after the brain, a little lazy suspicion ...

150313 that poor two-pillar classmate

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.