C语言指针与函数之三数比较大小并排序
2016-07-18 18:33
295 查看
#include <stdio.h>
void exchange(int *q1,int *q2,int*q3);
void swap(int *pt1,int *pt2);
int main()
{
int a,b,c,*q1,*q2,*q3;
scanf("%d%d%d",&a,&b,&c);
q1=&a;
q2=&b;
q3=&c;
exchange(q1,q2,q3);
printf("%d %d %d\n",a,b,c);
return 0;
}
void swap(int *pt1,int *pt2)
{
int temp;
temp=*pt1;
*pt1=*pt2;
*pt2=temp;
}
void exchange(int *q1,int *q2,int *q3)
{
if(*q1<*q2)
{
swap(q1,q2);
}
if(*q1<*q3)
{
swap(q1,q3);
}
if(*q2<*q3)
{
swap(q2,q3);
}
}
void exchange(int *q1,int *q2,int*q3);
void swap(int *pt1,int *pt2);
int main()
{
int a,b,c,*q1,*q2,*q3;
scanf("%d%d%d",&a,&b,&c);
q1=&a;
q2=&b;
q3=&c;
exchange(q1,q2,q3);
printf("%d %d %d\n",a,b,c);
return 0;
}
void swap(int *pt1,int *pt2)
{
int temp;
temp=*pt1;
*pt1=*pt2;
*pt2=temp;
}
void exchange(int *q1,int *q2,int *q3)
{
if(*q1<*q2)
{
swap(q1,q2);
}
if(*q1<*q3)
{
swap(q1,q3);
}
if(*q2<*q3)
{
swap(q2,q3);
}
}
相关文章推荐
- C语言的HelloWorld 过渡到 OC的HelloWorld
- 法国Nao机器人在C++开发中如何使用外部库
- 服务端与客户端握手规则,心跳逻辑
- jhash的C++实现
- jhash的C++实现
- jhash的C++实现
- jhash的C++实现
- jhash的C++实现
- jhash的C++实现
- ROS学习之 cpp定时器
- ip与int之间的转化函数
- ip与int之间的转化函数
- ip与int之间的转化函数
- ip与int之间的转化函数
- ip与int之间的转化函数
- ip与int之间的转化函数
- Cpp环境【Uva11572】【Vijos2788】唯一的雪花(并没有雪花=_=)
- C语言中函数strlen等的实现
- c/c++ 数组和指针的一些不同之处
- 下面对 C++ 静态数据成员的描述中,正确的是?