#include<stdio.h>
void sortData(int *a,int *b,int *c)
{
int temp1,temp2,temp3;
if(*a<*b)
{
temp1=*a;
*a=*b;
*b=temp1;
}
if(*a<*c)
{
temp2=*a;
*a=*c;
*c=temp2;
}
if(*b<*c)
{
temp3=*b;
*b=*c;
*c=temp3;
}
}
int main()
{
int a,b,c;
printf("input a:\n");
scanf("%d",&a);
printf("input b:\n");
scanf("%d",&b);
printf("input c:\n");
scanf("%d",&c);
/*
int a=3;
int b=5;
int c=6;
*/
sortData(&a,&b,&c);
printf("big to small:%d,%d,%d",a,b,c);
return 0;
}
使用指针进行访问地址,以达到改变数值目的