Today I have a magic algorithm, according to the editor is an easy and intresting book, so I began to open.
The author uses the C language, and I am recently eating python so I'm thinking of using Python to solve the author's questions.
This is not, the first page is coming, this is a very simple for the human brain, but for the academic knowledge of the full return to the teacher's people still think of long time, looked for a good while the information.
After thinking, I chose the array, and then search the Python knowledge of the array, the result, it seems that Python does not pay much attention to the array, or not the same, later looked at list and dict, think should be similar, after reference, also came out, really super simple, than the original ecological language implementation of a lot of simple
#!/usr/bin/python#-*-encoding=utf-8-*-a=[1]*5for i in Range (0,5): a[i]=input () a.sort (reverse=true) print a
Operation Result:
Input: 961027 Get results: [10, 9, 7, 6, 2]
is not very simple, only 5 lines of code, and are the most simple code, small white can also see it.
Summarize:
① Knowledge Points: The basic application of the sort function
This is a list of the sort method, the use is very simple, in the help document directly to see can understand, so lazy I directly stickers
The above shows are the positive sequence arrangement, that is, from small to large arrangement, but the topic requirements from large to small arrangement, so finally still rely on the Universal Blog Park, only to be resolved.
There's nothing to do in the blog Park or (゜▽^*))
②: The program really is to achieve the basic function, but the operation is very cumbersome, input data when I have to enter one, and finally must press ENTER to come out results, I want to see the author is how to solve, and then try to improve their own program!
Welcome to Exchange
(*^__^*) To work time to write blog, I This is enough boring, in order to brush my existence, I go back to work, I hope that small white and the great God can see, and then we exchange discussions together, walk in the program of the road!
Python for simple sorting