#include <iostream>
using namespace std;
int main()
{
void swap(int *p1,int *p2);
int *pointer_1,*pointer_2,a,b;
cin>>a>>b;
pointer_1=&a;
pointer_2=&b;
if(a<b)
{
swap(pointer_1,pointer_2);
}
cout<<"max="<<a<<" min="<<b<<endl;
return 0;
}
void swap(int *p1,int *p2)
{
int temp;
temp=*p1;
*p1=*p2;
*p2=temp;
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;
return 0;
}
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;
}
在主函数中调用函数比较三个数的大小
最新推荐文章于 2024-01-25 22:35:13 发布