Analysis of arithmetic problem generation program

Source: Internet
Author: User

PSP2.1

Personal Software Process Stages

Time

Planning

Plan

· Estimate

· Estimate how long this task will take

20h

Development

Development

· Analysis

· Demand analysis (including learning new technologies)

5h

· Design Spec

· Creating a design Document

2h

· Design Review

· Design Review (and colleagues review design documents)

1h

· Coding Standard

· Code specification (to develop appropriate specifications for current development)

1h

· Design

· Specific design

2h

· Coding

· Specific code

8h

· Code Review

· Code review

2h

· Test

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

2h

Reporting

Report

· Test Report

· Test report

1h

· Size Measurement

· Computational effort

1h

· Postmortem & Process Improvement Plan

· Summarize afterwards and propose process improvement plan

1h

Total

26h

Program Requirements:

1. Definition:
Natural number, true score (1/2,2/3,1 ' ... )
+-*/() = space (for arithmetic characters and before and after signs)
2. Enter:
(1) Use the-n parameter to control the number of generated topics:
Myapp.exe-n 10 (Generate 10 topics)
(2) Use the-R parameter to control the range of values (natural number, true fraction, and true fraction denominator) in the topic:
Myapp.exe-r 10 (generates 10 (excluding 10) arithmetic topics. This parameter must be given, otherwise the program will error and give help information. )
(3) The program supports a given problem file and answer file, determining the correct error in the answer and counting the numbers:
Myapp.exe-e <exercisefile>.txt-a <answerfile>.txt (the results are output to file Grade.txt in the following format:
Correct:5 (1, 3, 5, 7, 9)
Wrong:5 (2, 4, 6, 8, 10)
where ":" After the number 5 indicates the number of correct/wrong questions, in parentheses is the number of the right/wrong topic. )
3. Demand:
(1) The calculation process in the generated topic cannot produce negative numbers, that is, if there is a shape like E1 in an arithmetic expression? E2 subexpression, then e1≥e2.
(2) If there is a sub-expression like E1÷e2 in the generated topic, the result should be a true fraction.
!!! (3) The number of operators in each topic does not exceed 3.
(4) Any two topics cannot be transformed into the same topic by means of an arithmetic expression of finite exchange + and x or so. For example, 23 + 45 = and 45 + 23 = are repetitive topics, 6x8 = and 8x6 = are also repetitive topics.
!!! (5) The generated topic is stored in the Exercises.txt file under the current directory of the executing program, in the following format:
1. Arithmetic Topic 1
2. Arithmetic Topic 2
......
Where true scores are used in the input and output format, the true score Three-fifths is 3/5, the true fraction Two and three-eighths is 2 ' 3/8.
!!! (6) When generating the topic, the answers of all the questions are calculated and stored in the Answers.txt file under the current directory of the executing program, in the following format:
1. Answer 1
2. Answer 2
......
In particular, the operation of the true fraction is shown in the following example: 1/6 + 1/8 = 7/24.
(7) The program should be able to support the generation of 10,000 topics.
!!! (8) Keep track of how much time you spend improving program performance, describe your ideas for improvement, and show a graph of performance analysis (generated automatically by VS2012 's performance analysis tools). If possible, show the most expensive functions in your program.
!!! (9) Share at least 10 test cases that you have tested for your program, and explain why you can be sure that your program is correct. (Incorrect procedures get 0 points, regardless of performance)

Program Analysis:

1, the teacher set the programming language for c++/c#, but in fact so far we have only learned C and Java, so in the choice of the two languages still tangled up, the first use of C + +, and later found that C # and the use of Java very much like, and then overturned rewrite C #.

2, the topic at first glance seemed very simple, nothing more than random number generation, but the careful reading suddenly found that the teacher's request and then basically dragged on for a long time, There are a lot of things to think about in design:

  1. parameters both natural numbers and true fractions , so a class is defined to determine the type of the number.
     public  class   Figure { private  int   number;  private  int  Denominator;// fenmu  private  int  numerator; //        fenzi  private  int      iffraction; }
  2. When the symbol is generated, "+" "-" "*" "/" are all defined in an array, and randomly selected symbol processing is generated based on random numbers. The selection is also generated by a 0/1 random number to choose whether to leave parentheses.
  3. Consider the command line parameter input, set two input processing mode module,myapp.exe-e <exercisefile>.txt-a <answerfile>.txt, and myapp.exe-n n -R R (n is the number of generated topics, R is the range).
  4. The calculation part is written out separately to put in a class method, using infix expression to generate prefix expression, and prefix expression algorithm.
  5. Test and generate each signal indicator, generate part of the answer generation, as read into the Exercises.txt file regenerated into Answers.txt file.

3. Test Case:

No1.txt-n 10-r 10

No1.txt-n 100-r 10

No.1.txt-n 10000-r 10000

Performance Analysis Diagram:

Analysis data: No1.txt-n 10000-r 10000

Analysis of arithmetic problem generation program

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.