没注释的源代码
#include <iostream>
using namespace std;
void swap(int *m,int *n);
int main()
{
int a,b,c;
int *p1,*p2,*p3;
cout<<"请输入三个整数:"<<endl;
cin>>a>>b>>c;
p1=&a;p2=&b;p3=&c;
if(a>b) swap(p1,p2);
if(a>c) swap(p1,p3);
if(b>c) swap(p2,p3);
cout<<"排序后的结果:"<<a<<" "<<b<<" "<<c<<endl;
return 0;
}
void swap(int *m,int *n)
{
int temp;
temp=*m;
*m=*n;
*n=temp;
}
标签:p2,p3,p1,temp,int,C++,由小到大,swap,指针 From: https://blog.csdn.net/2303_80770781/article/details/142534648