用指针将三个整数从小到大排序

来源:互联网 发布:魅色软件官方网站 编辑:程序博客网 时间:2024/06/06 02:23
#include<cstdio>#include<algorithm>#include<iostream>#include<cmath>#include<iomanip>#include<string>#include<cstring>using namespace std;void swap(int *p1, int *p2){    int p;    p=*p1;    *p1=*p2;    *p2=p;}int main(){    int a, b ,c;    int *p1, *p2, *p3;    scanf("%d%d%d", &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);    printf("%d %d %d", a, b, c);    return 0;}

指针小白默默爬走。。。