ACM exercise (7.3)

 

 1, the module string:

Need to pay attention to the small details:

char to an int type conversion: char-> int: - '0'

char to an int converter: int-> char: + '0'

Input string getline (cin, s)

When the need to enter a plurality of strings, the string itself to see whether the title content is the need to output the result, if not, may not need to define a plurality of strings

 

Question Example 1: Digital inversion problem (signed numbers: integers, fractions, decimals, percentages), before and after the sign inversion points

Solving points: before and after the position is divided into two portions symbols and, marks and symbols stored directly outputs the first half (four cases are the same, attention to the problem of reverse rotation prefix 0), the latter half sub-four cases export

 :( only part of the code by 70%, should be the precision control of ...)

https://paste.ubuntu.com/p/6PcwCvfR2g/

 

Example 2 questions: matching characters

Solving points: before and matching words and after are matched segments with "" This method can prevent the head and tail is determined article

Code section:

 

2, the recursive function

 

l understand the topic is very important!

l flexible to find the law in question, not necessarily violent solving (problem Example: To calculate the number of)

l problem typically occurs recursive computation time exceeds the limit, it can be used instead of the recursive use of recursive flexible (title Example: Calculation of the)

l look with a certain number of features within a certain range, the next one into manufacturing this case the number of features easier in this range. (E.g., find palindrome in 1000, a number of selectable manufactured with palindromic feature within 1-1000) (Example question: palindromic prime)

Note that the length l of data defined over a range of problems

l and clever use of recursive backtracking (title example: the number of election)

 

Question Example 1 : matchstick equation

Link: https: //paste.ubuntu.com/p/kX62qsGkF2/

题例 2: palindromic prime

Link: https: //paste.ubuntu.com/p/qhdsYNDP7J/

Question 3 cases: The number of selected ( problem-solving elements: dfs depth-first search, recursive thinking)

链接:https://paste.ubuntu.com/p/KMdNdFDKwg/

题例4:数的计算(解题要点:寻找规律进行递推

链接:https://paste.ubuntu.com/p/Gd9xDzGVQC/

 

 

Guess you like

Origin www.cnblogs.com/SUHANG12138/p/11129189.html