标签:*
#include<stdio.h>
void exchange(int *q1, int *q2, int *q3)
{
void swap(int *w1, int *w2);
if (*q1 < *q2)swap(q1, q2);//这里的顺序不能乱改
if (*q1 < *q3)swap(q1, q3);
if (*q2 < *q3)swap(q2, q3);
}
void swap(int *w1, int *w2)
{
int temp = 0;
temp = *w1;
*w1 = *w2;
*w2 = temp;
}
int main()
{
int a = 0, b = 0, c = 0;
int *p1 = 0, *p2 = 0, *p3 = 0;
printf("please ente three number:");
scanf("%d%d%d", &a, &b, &c);
p1 = &a, p2 = &b, p3 = &c;
exchange(p1, p2, p3);
printf("%d %d %d", a, b, c);
system("pause");
return 0;
}
标签:*
原文地址:http://10942013.blog.51cto.com/10932013/1727719