C language: Using pointer variables, the function implementation of the 3 integers in order from large to small output

Source: Internet
Author: User

Using pointer variables, the function implements the output of 3 integers in order from large to small.

Solution: Program:

#include <stdio.h>


void swap (int *ptr1, int *ptr2)

{

int temp = *PTR1;

*PTR1 = *PTR2;

*PTR2 = temp;

}


void Exchange (int *q1, int *q2,int *q3)

{

void swap (int *ptr1, int *ptr2);

if (*q1 < *Q2)

{

Swap (Q1, Q2);

}

if (*q1 < *Q3)

{

Swap (Q1, Q3);

}

if (*q2 < *Q3)

{

Swap (q2, Q3);

}

}


int main ()

{

void Exchange (int *q1, int *q2, int *q3);

int *P1, *P2, *p3, A, b,c;

printf ("Please enter three integer numbers:");

scanf ("%d,%d,%d", &a,&b,&c);

P1 = &a;

P2 = &b;

P3 = &c;

Exchange (P1, p2, p3);

printf ("The Order is:%d,%d,%d\n", a,b,c);

return 0;

}

Results:

Please enter three integer numbers:7,-9,666

The Order is:666,7,-9

Please press any key to continue ...


This article is from the "Rock Owl" blog, please be sure to keep this source http://yaoyaolx.blog.51cto.com/10732111/1751267

C language: Using pointer variables, the function implementation of the 3 integers in order from large to small output

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.