Computer program design art (Volume I) (continued 2)

xiaoxiao2021-03-06  83

3) Enter an algorithm with 0 or more inputs. It is the amount of the algorithm to the algorithm before it begins before the algorithm begins. These inputs are taken from a particular object collection. For example, in the algorithm E, there are two inputs, ie M and n, which are taken from the positive integer set.

4) Output an algorithm has one or more outputs. It is, the same amount of a particular relationship is input. The algorithm E has an output, namely the n in step E2, which is the greatest public factor of two inputs.

(This is indeed the biggest public factor, we can easily prove as follows. After step E1, we have

M = Qn R

Where Q is an integer. If r = 0, then M is a multiple of N, and it is obvious that in this case, n is the maximum factor of M and N. If r ≠ 0, pay attention to any number of m and n two numbers must also be divided by m-Qn = R, and at the same time, the number of N and R must be divided by qn r = m; The set of common cavities of M and N must be the same as the common set of N and R, and, in particular, the maximum common factors of M and N are the same as the maximum common factors of N and R. Therefore, step E3 does not change the answer to the original problem).

5) It is generally possible to say that one algorithm is also possible. This means that all operations to be implemented in the algorithm must be quite basic, ie, they are in principle, and people can do with pen and paper. The algorithm E uses only one positive integer divided by another positive integer, and tests whether an integer is 0, and sets the value of a variable is equal to the value of another variable. These calculations are possible, because integers can be represented on paper in a poor manner, and at least one method ("removal algorithm") is used to perform an integer divided by another integer. However, if the value of the two numbers is determined by the infinite ten progress, the same calculation is not possible. If the value of the two numbers cannot be accurately determined, the same operation is not possible. Another example of a non-row of step is, "If 2 is the N times of the N times of the equation 'X Y, the N times in the N times, the N-mover' is the largest solution X, Y, Z is the largest. The integer is made step E4. " Such a statement is not a line of operation unless someone can explain whether or not there is a maximum integer of the nature.

(Endlessly)

转载请注明原文地址:https://www.9cbs.com/read-107323.html

New Post(0)