In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains the "PHP simple bubble sort code sharing", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "PHP simple bubble sort code sharing" bar!
The copy code is as follows:
Php Bubble sort 2
The basic concept is to compare two adjacent numbers in turn, putting the decimal in front and the large number in the back. That is, first compare the first and second numbers, putting the decimal before the large number. Then compare the second number and the third number, put the decimal before the large number, and so on, until you compare the last two numbers, put the decimal before the large number. Repeat the above process, still start from the first logarithm (because it is possible that the first number is no longer less than the second number due to the exchange of the second number and the third number), put the decimal number before, after the large number, compare to a pair of adjacent numbers before the maximum number, put the decimal number before, after the large number, at the end of the second round, and get a new maximum number in the penultimate number. Go on like this until the sorting is finally completed.
Because decimals are always put forward and large numbers are put back in the sorting process, which is equivalent to the rise of bubbles, it is called bubbling sorting.
It is realized by a double loop, with the outer loop variable set to I and the inner loop variable set to j. The outer cycle was repeated 9 times, and the inner cycle was repeated 9 times in turn. The two elements compared each time are related to the inner loop j, and they can be identified by a [j] and a [j + 1] respectively. The value of I is 1, 2, respectively. For each I, j
The values are in the order of 1, 2, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 2, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 and 4 respectively.
The copy code is as follows:
Demonstration of PHP bubble sorting method
In the past, the written questions issued by the examiners during the interview were more XX, and the program should be written on the computer, not on the pen.
PHP program file sort_bubble_up.php
The copy code is as follows:
Demonstration of bubbling sorting method
Demonstration of bubbling sorting method
Style sheet file sort.css
The copy code is as follows:
H2 {text-align: center; color: blue;}
Table {font-size: 12px; font-family: arial; background-color: black; text-align: center;}
Td {background-color: white;}
.base {background-color: # 0FF;}
.light {background-color: # 0DD;}
.title {background-color: # 3FF; text-align: center;}
Thank you for your reading, the above is the content of "PHP simple Bubble sorting Code sharing". After the study of this article, I believe you have a deeper understanding of the problem of PHP simple Bubble sorting Code sharing, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.