#include <iostream>
#include <string>
#include <windows.h>
using namespace std;

void swap(int* a, int* b) {
    int tmp = *a;
    *a = *b;
    *b = tmp;
}
int main() {
    int a[3] = { 7,2,5 };
    if (*a > *(a + 1)) {
        swap(a, a + 1);
    }
    if (*(a + 2) < *(a + 1)) {
        swap(a + 1, a + 2);
        if (*(a + 1) < *a) {
            swap(a, a + 1);
        }
    }
    for (int i = 0; i < sizeof(a) / sizeof(a[0]); i++) {
        cout <<  a[i] << " ";
    }
    cout << endl;

    system("pause");
    return 0;
}

posted on 2022-10-08 16:52  wshidaboss  阅读(21)  评论(0编辑  收藏  举报