In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how to use C++ recursion to achieve the selection sorting algorithm, which has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article. Next, let the editor take you to know about it.
Basic thought
Each time you find the smallest element, use the exchange implementation to put it in the first place in disorder until all the elements have been sorted.
Give an example
Take A [10] = {3] 1, 6, 4, 8, 2, 10, 7, 9, 5} as an example
The first selection sort: sort position 0, element 1 is the smallest element after position 0, then swap (A [0], A [1])
That is, 1, 3, 6, 4, 8, 2, 10, 7, 9, 5, then position 0 is ordered, and position 0 is out of order.
The second selection sort: sort position 1, element 1 is the smallest element after position 1, then swap (A [1], A [5])
That is, 1 2 6 4 8 3 10 7 9 5, then position 1 is in order, and position 1 is disordered after position 1.
... ...
Complete code / / Select sort, compilation environment Dev C++#include # include using namespace std;void sort (int spenint treint arr []) / a pair of arr [s.t] to select sort {if (s)
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.