Arithmetic Generator--impressions

Source: Internet
Author: User
Tags strtok

1. Estimated time and actual time spent in the table

               The ideal is too plump to show too much backbone

PSP2.1

Personal Software Process Stages

Time

Planning

Plan

· Estimate

· estimate how long this task will take

15h

Development

Development

· Analysis

· Demand Analysis (including learning new technologies )

2h

· Design Spec

· Creating a design document

2h

· Design Review

· Design Review (and colleagues review design documents )

3h

· Coding Standard

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

1h

· Design

· Specific Design

0.5h

· Coding

· Specific Code

10h

· Code Review

· Code Review

2h

· Test

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

5h

Reporting

Report

· Test Report

· Test Report

1h

· Size Measurement

· Computational effort

0.5h

· Postmortem & Process Improvement Plan

· summarize afterwards and propose process Improvement plan

0.5h

Total

27.5h

2. Algorithmic thinking

This time the topic is actually two procedure (very cannot understand this to do the purpose ....) ), a task is: to generate arithmetic expressions, their own operation of the answer, the other task is: according to the given topic file and answer file, judge the correct or false.

At first I thought the first task was relatively simple, because at the time it felt that the precedence between the comparison operators was troublesome, first to be converted to a suffix, then to calculate, always wanted to avoid this problem, and eventually did not bypass. The first task, the main idea

is: Before generating a calculation, the man is a random number to judge that there will be several operators in the equation, and the generation of integers and fractions is determined by a random number, and it is important that integers also look at the number of components (integers/1). and then

Each time the loop, randomly generate a number and operator, and use the operator to decide whether to add parentheses (the random number is really a very magical thing), these are generated, it is necessary to call the deal () function to determine whether the sub-formula is negative (pupils do not understand

Negative... ), and in this decision whether to discard the generated numbers and operators;

After a formula is generated, the play comes, check the weight!! I think a lot of methods, but for my program, the operation is more difficult, in the end, I chose a very "cheap" method, direct comparison of the answer, each generation of a formula, make its answer

The case is compared with all of the previous formulas, if found equal, then embarrassed, this generation of the formula can be gone, directly shed! I tried to generate 100 questions, the operation of the answer will generate more than 20 questions; Generate 1000 lanes

, more than 300 will be generated, but more than 7000 will be generated when 10000 questions are generated!! Cough, this is not the point, the focus is no repetition of the topic (I also think this efficiency is a bit low), and then OK.

The second task, relative to the first one, is quite simple, as long as you scan the title file and apply the function in the first task to achieve it.

3. Program Analysis

      This is the command when testing the-R 10-n 1000, the generated diagram, on the to_string took a long time, in the performance of the lifting program, but also think of a lot of methods, but ultimately did not greatly improve, only in part

function to improve a bit of performance, no way ....

This is the generated diagram when testing the-e 1.txt-a 2.txt command

In the process of program generation, there are also several important issues (for me):

1. Problems with fractional operations

Because the program involves the problem of the score, so in the calculation, there will be-pass, numerator and other problems;

2. Problems with storing data

Because of the range of int, there may be more than the int range number in the operation process;

3.substr () function

The substr () function differs from Java in C + + (this point pits me), substr (int 1,int 2) 2 indicates that the length of the string to intercept is not the character position in Java;

4.strtok () function

This function is similar to spilt () in Java, Char *strtok (char s[], const char *delim);

Decomposes a string into a set of strings. S is the string to be decomposed, Delim is the delimiter string.

For example: Strtok ("Abc,def,ghi", ","), and finally can be divided into ABC def GHI. but note that the s here is char*, not string s。 4. Test Cases

   1. When testing the-R x1-n X2 command:

X1 can not be greater than 100, although the program pro-Test 1000 or less may be generated, but the time is too long, not count!

2. Sizeyunsuan.exe-n 10000-r 100

Generate 10,000 formulas with a range of 100 or less

3. Sizeyunsuan.exe-e exercise.txt-a Answer.txt

Check the answer in two files, generate the result in Grade.txt

4. Sizeyunsuan.exe-n 10

Prompt to enter correct and complete parameters

5. Sizeyunsuan.exe-r 10

Prompt to enter correct and complete parameters

6. Sizeyunsuan.exe-e Exercise.txt

Prompt to enter correct and complete parameters

7. Sizeyunsuan.exe-a Answer.txt

Prompt to enter correct and complete parameters

8. Sizeyunsuan.exe-n 10001-r 100

Prompt for the correct number of questions to be entered

9. Sizeyunsuan.exe-n 1000-r-1

Prompt for the correct number of ranges to be entered

SIZEYUNSUAN.EXE-E 1.txt-a Answer.txt

Hint file 1.txt does not exist

SIZEYUNSUAN.EXE-E exercise.txt-a 2.txt

Hint file 2.txt does not exist

Sizeyunsuan.exe-n 10000-r 100-e exercise1.txt-a answer1.txt

Generate the problem and complete the verification, two functions are completed sequentially

5. Personal sentiment

     The ideal is very plump, the reality is very backbone, I first see the topic, although feel a bit of trouble, but still feel more easy to write, use an afternoon time to write the whole program, and then found ... and poor demand

A bit more, struggled for a long time between rewriting and maintaining previous ideas, and ultimately "yielding"-rewrite!

Although "after difficult", but still finished, feel still learned a lot, no deadline of persecution, is not in such a short time to write.

Arithmetic Generator--impressions

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.