Get the App
SLTechnology News&Howtos  ›  Development  › 

How to understand the ordering in the basis of C language

Shulou Source: shulou.com Published: 2022-06-02 10:58:21 11月14日 Update

What this article shares with you is about how to understand the ranking in the basis of C language. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article. Let's take a look at it with the editor.

Bubble sort Bubble sort (classic simple sorting algorithm)

How it works: a set of data in which two adjacent numbers are compared and exchanged in the order from small to big or from big to small; the comparison is repeated until there is no longer need to exchange, that is, the set of data is sorted.

Array to be sorted: 6 2 4 3 8 1 7 9 5

According to the principle of Bubble sort:

1. From the start data 6 > > end data 5 as a big cycle

two。 The first big cycle begins: the comparison of adjacent pairs of data is part of this big cycle. If the comparison meets the conditions, it will be exchanged until the last pair of data is compared, and the big cycle ends.

3. Repeat the operation, do the second big cycle from the starting data, and repeat the adjacent data comparison.

The basic way of writing:

# include int main (void) {int iRecitemjret; int Arr [9] = {6, 2, 4, 3, 8, 1, 7, 9, 5); for

Tags: Data sorting big cycle foundation language language foundation writing method principle more knowledge article starting practical from small to big two that is from childhood function that is Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Huawei vpn Shulou Tech Info OPPO Reno