Arithmetic development notes for compute and generators

Source: Internet
Author: User

This secondary work is divided into two parts: first: The program should be able to arithmetic the problem of random generation, two: The program can be given the question and answer the right and wrong judgment, and give the results of the decision.

Estimated time and actual cost schedule

PSP2.1

Personal Software Process Stages

Time

Planning

Plan

· Estimate

· estimate how long this task will take

24 hours

Development

Development

    analysis

     demand analysis   (including learning new technology "

 3 hours

· Design Spec

· Creating a design document

2 hours

· Design Review

· Design Review (and colleagues review design documents )

1 hours

    coding standard

     Code specification   (to develop appropriate specifications for current development

  1 hours

· Design

· Specific Design

2 hours

· Coding

· Specific Code

4 hours

· Code Review

· Code Review

1 hours

· Test

· Test (self-test, modify code, commit changes)

3 hours

Reporting

Report

· Test Report

· Test Report

4 hours

    size measurement

     Computational effort

 1 hours

· Postmortem & Process Improvement Plan

· summarize afterwards and propose process Improvement plan

1 hours

Total

23 hours

Design Analysis:

First is the first function, the requirement is: 1,. Negative numbers are not allowed, 2. The operator for each operation is not more than three, 3. The expression of the score in the formula and the result should use the true fraction, 4. The multiple-path problems generated should be different topics, that is, any two topics cannot be transformed into the same topic by means of an arithmetic expression of finite Exchange + and X. Of course, there are limits on the number of generated topics and the range of operations, which are easy to do and not to repeat.

Then there is the process of implementing the requirements. For negative numbers, only the subtraction overload is required, and if a negative number is present, the position of the meiosis and the meiosis is exchanged. Operator does not exceed three, the number of operators can be determined by a random number of 1-3. For the processing of true fractions, I used a number class to process fractions and integers at the same time and redefine the way subtraction. The problem is generated using the following procedure: 1: Randomly a 1-3 integer to determine the number of operators

2: Randomly generate the corresponding number of operators and number class objects

3: Randomly out the operation priority of each operator, and determines the parentheses according to the precedence and self-

Have the has no corresponding position

4: Send the deterministic expression to the corresponding file as a string

Where the number class is defined as the following class shuzi{

Public:int Fenzi;

int Fenmu;

......                      }

If the integer is the denominator 1. And the class defines the subtraction operation for the object of the class.

Of course, there is one more feature that needs to be implemented: removing duplicate expressions. I use the following method for the determination of the repeating expression: to rearrange the resulting string, the orchestration follows the following rules: for the left and right two numbers to be added or multiplied, the large is placed in front by the result of the comparison size, and the two numbers with parentheses for each addition or multiplication are required. You can then get rid of the same formula by comparing the string equality and regenerate the new formula. Here, the generation of the arithmetic formula has been completed.

Then is the implementation of the second function, here only need to write a computational function, the calculation method is to read the infix expression through the queue and stack to the suffix expression, and then do the calculation, about the conversion method in the data structure book is detailed introduction, here also no longer repeat.

The above is for the work of the needs of the implementation and processing, the next talk about the work encountered in the problem and get the harvest. The first is the question of language. Prior to the C + + has no understanding, so in the code writing process, some grammar and library function application let me very headache. There is to pay special attention to the data structure and some common algorithms of proficiency and use, to apply this knowledge to the actual life, to be based on the actual, service life.

Arithmetic development notes for compute and generators

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.