//输入三个整数,按由小到大的顺序输出
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void sortInt(int p[]);
int main()
{
int date[3]; //定义一个指针型数组
int i;
printf("piease scanf three numbers:");
for(i=0;i<3;i++)
{
date[i]=(int*)malloc(3);
scanf("%d\n",*date[i]);
}
sortInt(date);//定义的函数,需要输入其地址。
printf("%d%d%d\n",date[0],date[1],date[2]);
for(i=0;i<3;i++)
{
free(date[i]);
date[i]=0;
}
return 0;
}
void sortInt(int *p[])
{
int *temp;
if(p[0]>p[1])
{
temp=p[0];
p[0]=p[1];
p[1]=temp;
}
if(p[0]>p[2])
{
temp=p[0];
p[0]=p[2];
p[2]=temp;
}
if(p[1]>p[2])
{
temp=p[1];
p[1]=p[2];
p[2]=temp;
}
}