Software Engineering Personal Assignment 04

Source: Internet
Author: User

"Design Ideas"

defines a 4The number of groups, respectively, isBracket[4],Numberzi[4],Numberm[4],Sign[4]. Bracketused to store parentheses,2On behalf of Double,1represents the wrong parenthesis,-1represents the closing parenthesis,-2represents the right pair,0without parentheses, initially as0;Numberzifor storing molecules,Numbermustores the denominator, Signstores symbols. Defining integral TypesSui, used to limit the length of the formula, randomly generated, value2-4.. Defining integral Typestype, the value range0-1,1represents a fractional operation. For each formula that is randomly generated, the length of theSui, forLoopsSui, GenerateNumberzi[i],Numbermu[i](When an integer, take the1),Sign[i](fromi>0start random value, range0-1, when generating symbols, determine if multiplication is required, and then extend the range of values to0-3). When a score is generated, the value range of the denominator isNumberzi-high(maximum value). When the number of loops is greater than the moment, determine the size of the two numbers before and after the symbol and operator to see if they need to be swapped for the position (to satisfy subtraction minus negative, division positive fraction).

numerator : When fractional (numbermu==1), the numerator is assigned to the shaping variable cc, for Loop cc--until the numerator and denominator divide the cc, divide the operation, and break;

parentheses: This part uses the dead method and takes all the circumstances into account. When the operation is four numbers, it is divided into three cases,1.Double brackets: There are four positions in the double parenthesis, the first number before theBracket"0"=2, "1"=-1, "2"=-1. The second number is followed by the third number, after the fourth number. 2.parentheses: The first two digits, the first three digits, the last two digits, the middle two digits, the next three digits, the first two numbers, and the last two digits. 3.no parentheses. When the number of operands is three, there are only two cases at this time:1.only one parenthesis, the first two digits, and the last two digits2.no parentheses. When the number of operands is2, there is no parenthesis.

Output: for Loops Sui , when i=0 the output is not Sign ; Judge type value, determines the format of the formula, the integer output only Numberzi , the score is all output.

Calculation: First judge the case of parentheses, single-pair ((a B) (C D), but the parentheses are counted. Double brackets left double and right double, left double: start with a double parenthesis, look for the next closing parenthesis, calculate the operation in parentheses (first multiplication, then add minus), then store the result in the position of the previous number, then move the subsequent number forward (Bracket, Sign,Numberzi,Numbermufull shift), and then calculate again until the parentheses are computed, and then look for the next parenthesis, just as the operation is pointing to no closing parenthesis; the closing parenthesis is similar. Parentheses: Computes the operation in parentheses, moving the subsequent number forward until there is no closing parenthesis. Each time an operation is performed, thesui--. No parentheses: forLoopsSui, direct operation (first multiplication, then add minus). The array is moved forward. (Note: The parentheses and the brackets are the same level, and the two end up with an operation without parentheses)

result Output: simplificationNumberzi"0"withNumbermu"0"and judging ifNumbermu"0"=1, the result is an integer, and the outputNumberzi"0"Otherwise the outputNumberzi"0"withNumbermu"0".

Result Validation : The result is converted into a string format (simplified), and the results of user input are saved in a string, comparing the two.

"Time History Table"

Date Start time End time Total Activities Note
2016.3.28 8.00 10.00 100 Class
2016.3.29 15.20 18.00 150 Reading discussion Write it first, in the web version.
2016.3.30 15.00 17.00 120 Design program
2016.3.31 15.30 17.40 130 Programming Java
2016.4.4 19.00 21.00 120 Programming Java
2016.4.5 19.00 21.30 150 Programming Java
2016.4.6 15.00 21.00 240 Programming, finding the wrong Eat
2016.4.7 15.30 21.00 200 Find the wrong Eat
2016.4.9 15.00 21.00 200 Change the wrong Eat
2016.4.10 15.00 19.00 200 Write the program as a web version Jsp
2016.4.11 8.00 10.00 100 Class
2016.4.12 15.00 21.00 240 Continue to change the program to Web version

Software Engineering Personal Assignment 04

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.