Question 12: Compile the template function sort to sort the three parameters a, B, and c in ascending order.

Source: Internet
Author: User

/*************************************** ************************
C Language

AUTHOR: liuyongshui
DATE :********
**************************************** ***********************/
/*
Question 12: Compile the template function sort to sort the three parameters a, B, and c in ascending order.

*/

# Include <stdio. h>

Void sort (int l, int m, int n); // statement of the original function

Int main ()
{
Int;
Int B;
Int c;

Printf ("Enter three numbers :");
Scanf ("% d", & a, & B, & c );
Sort (a, B, c );

Return 0;
}


// Function Definition
Void sort (int l, int m, int n)
{
Int t;

If (l <m) // compare the sizes of l and m
{
T = l;
L = m;
M = t;
}
If (l <n) // compare the sizes of l and n
{
T = l;
L = n;
N = t;
}
If (m <n) // compare the sizes of m and n
{
T = m;
M = n;
N = t;
}

Printf ("after sorting, from large to small: % d \ n", l, m, n );
}

Related Article

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.