上学期刚学的,这学期就忘了
#include <iostream>
using namespace std;
int main()
{
void select_sort(int *p1,int *p2);//声明函数
int a,b,*pointer_1,*pointer_2;
cin>>a>>b;
pointer_1=&a;
pointer_2=&b;
cout<<"pointer_1="<<pointer_1<<" pointer_2="<<pointer_2<<endl;
if(a<b)
select_sort(pointer_1,pointer_2);//调用函数
cout<<"max="<<a<<" min="<<b<<endl;
cout<<"pointer_1="<<pointer_1<<" pointer_2="<< pointer_2<<endl;
pointer_1=&a;
pointer_2=&b;
cout<<"pointer_1="<<pointer_1<<" pointer_2="<< pointer_2<<endl;//用来对比指针指向的地址是否变化
return 0;
}
void select_sort(int *p1,int *p2)
{
int t;
t=*p1;
*p1=*p2;
*p2=t;
}
有图片,见相册。