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:
- Avoid duplication of topics
- can be customized (quantity, printing method);
- 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:
- 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).
- 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
- 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.
- 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:
- 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.
- Customization: Enter the number of topics, and print the same way, using [x + + if (x==?) Cout<<endl;]
- The multiplication method, which extracts the symbols of each topic at the time of printing, is compared. Other similar.
- 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