Sort by array variable pointer Selection

Source: Internet
Author: User

Adapt the previous article to use the selection method to calculate 10 integers in ascending orderChange sorting order to pointer

# Include "stdio. H "<br/> void main () <br/>{< br/> void sort (int * X, int N); <br/> int A [10], i, * P; <br/> P = A; <br/> for (I = 0; I <10; I ++) <br/> scanf ("% d", P ++); <br/> printf ("/N"); <br/> P =; <br/> sort (p, 10); <br/> for (P = A; P <A + 10; P ++) <br/> printf ("% d", * P); <br/>}< br/> void sort (int * X, int N) <br/>{< br/> int I, J, K, T; <br/> for (I = 0; I <n-1; I ++) <br/> {<br/> K = I; <br/> for (j = I + 1; j <n; j ++) <br/> If (* (x + J)> * (X + k) k = J; <br/> If (K! = I) <br/> {T = * (x + I); * (x + I) = * (x + k); * (x + k) = T ;}< br/>}< br/> 

For beginners, I only know the following sorting methods: 1. Select method 2. Bubble Method 3. Fast sorting (not used currently). Try again next time.

Looking at multi-dimensional arrays.

Encourage yourself every day and make progress every day! Xi

Stick to it!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.