作者在 2011-10-10 23:20:39 发布以下内容
#include <stdio.h>
void main()
{
void swap(int *pt1,int *pt2);
int n1,n2,n3;
int *p1,*p2,*p3;
printf("please input three n1,n2,n3:\n");
scanf("%d,%d,%d",&n1,&n2,&n3);
p1=&n1;
p2=&n2;
p3=&n3;
if(n1>n2) swap(p1,p2);
if(n1>n3) swap(p1,p3);
if(n2>n3) swap(p2,p3);
printf("Now, the order is %d, %d, %d\n", n1, n2, n3);
}
void swap(int *pt1,int *pt2)
{
int temp;
temp=*pt1;
*pt1=*pt2;
*pt2=temp;
}
void main()
{
void swap(int *pt1,int *pt2);
int n1,n2,n3;
int *p1,*p2,*p3;
printf("please input three n1,n2,n3:\n");
scanf("%d,%d,%d",&n1,&n2,&n3);
p1=&n1;
p2=&n2;
p3=&n3;
if(n1>n2) swap(p1,p2);
if(n1>n3) swap(p1,p3);
if(n2>n3) swap(p2,p3);
printf("Now, the order is %d, %d, %d\n", n1, n2, n3);
}
void swap(int *pt1,int *pt2)
{
int temp;
temp=*pt1;
*pt1=*pt2;
*pt2=temp;
}