简单的指针三个数排序
2009-11-12 13:06
197 查看
Code:
#include<iostream>
using namespace std;
int main()
{ void exchange(int *,int *,int *);
int a,b,c,*p1,*p2,*p3;
cin>>a>>b>>c;
p1=&a;p2=&b;p3=&c;
exchange(p1,p2,p3);
cout<<a<<" "<<b<<" "<<c<<endl;
}
void exchange ( int *q1,int *q2,int *q3)
{ void swap(int *,int *);
if(*q1<*q2) swap(q1,q2);
if(*q1<*q3) swap(q1,q3);
if(*q2<*q3) swap(q2,q3);
}
void swap (int *pt1,int *pt2)
{int temp;
temp=*pt1;
*pt1=*pt2;
*pt2=temp;
}
#include<iostream>
using namespace std;
int main()
{ void exchange(int *,int *,int *);
int a,b,c,*p1,*p2,*p3;
cin>>a>>b>>c;
p1=&a;p2=&b;p3=&c;
exchange(p1,p2,p3);
cout<<a<<" "<<b<<" "<<c<<endl;
}
void exchange ( int *q1,int *q2,int *q3)
{ void swap(int *,int *);
if(*q1<*q2) swap(q1,q2);
if(*q1<*q3) swap(q1,q3);
if(*q2<*q3) swap(q2,q3);
}
void swap (int *pt1,int *pt2)
{int temp;
temp=*pt1;
*pt1=*pt2;
*pt2=temp;
}
相关文章推荐
- 指针交换三个数 排序输出
- 三个简单的排序方法
- 三个简单的n方的排序
- 第十七周项目1-2-三个数排序(指针和引用)
- C语言 指针方法实现三个数排序
- 输入三个数字使用指针进行排序(冒泡原理)
- Java实现对三个数字的排序----简单易懂
- 联系指针——排序【输入三个数,从大到小输出】
- 三个简单、基本的排序算法---插入排序、选择排序、冒泡排序
- 用指针将三个整数从小到大排序
- 使用指针交换两个数的值 并且定义三个整型和三个整形变量且只用指针给三个数排序
- 【指针】【引用作形参】对三个变量排序
- 1919: 三个整数排序(指针专题)
- C语言三个数排序(利用指针)
- SortedList、SortedSet、HashSet、Hashtable、Dictionary、SortedDictionary 排序/可重复排序/过滤重复排序等简单对比
- 【数据结构】算法10.9 选择排序-简单选择排序
- 简单排序
- 简单插入排序的C语言实现
- 简单的批处理整人技巧_只需三个命令即可
- 一条单链表可以表示一个一元多项式,每个节点包含三个域:指数、系数和后继节点(指针或引用)。