#include <stdio.h>
int main()
{
void exchange(int* p1, int* p2, int* p3); //函数声明//
int a, b, c, * p1, * p2, * p3;
printf ("Please enter a,b,c:\n");
scanf ("%d%d%d", &a, &b, &c);
p1 = &a;
p2 = &b;
p3 = &c;
exchange(p1, p2, p3); //调用函数//
printf("%d,%d,%d\n", *p1, *p2, *p3);
return 0;
}
void exchange(int* p1, int* p2, int* p3) //定义将3个变量的值交换的函数//
{
void swap(int* p1, int* p2); //函数声明//
if (*p1 < *p2) swap(p1, p2); //调用函数//
if (*p1 < *p3) swap(p1, p3);
if (*p2 < *p3) swap(p2, p3);
}
void swap(int* p1, int* p2) //定义交换值的函数//
{
int temp;
temp = *p1;
*p1 = *p2;
*p2 = temp;
}
标签:p2,p3,p1,int,void,整数,C语言,swap,指针 From: https://blog.51cto.com/u_15865347/5900556