# [Procedure 37]

Source: Internet
Author: User
【 Program37]
Question: Sorting 10 numbers
1. Program Analysis: You can use the selection method, that is, from the last nine comparison processes, select a minimum element to exchange with the first element,
Next time, compare and exchange the second element with the last eight.
2. Program Source code:
# Define N 10
Main ()
{Int I, j, Min, TEM, A [n];
/* Input data */
Printf ("Please input ten num:/N ");
For (I = 0; I <n; I ++)
{
Printf ("A [% d] =", I );
Scanf ("% d", & A [I]);}
Printf ("/N ");
For (I = 0; I <n; I ++)
Printf ("% 5d", a [I]);
Printf ("/N ");
/* Sort ten num */
For (I = 0; I <N-1; I ++)
{Min = I;
For (j = I + 1; j <n; j ++)
If (A [Min]> A [J]) min = J;
TEM = A [I];
A [I] = A [Min];
A [Min] = TEM;
}
/* Output data */
Printf ("after sorted/N ");
For (I = 0; I <n; I ++)
Printf ("% 5d", a [I]);
}
========================================================== ======================================
Related Keywords:

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.