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