#include <iostream>
#include <algorithm>
using namespace std;
int arr[] = {4, 2, 3, 1};
bool cmp(int back, int front)
{
for(int i = 0; i < 4; ++i)
cout << arr[i] << ' ';
cout << '\n';
cout << "front = " << front << " back = " << back << '\n' << '\n';
return back > front;
/// ?
/// true exchange position
/// false do nothing
}
int main()
{
sort(arr, arr + 4, cmp);
for(int i = 0; i < 4; ++i)
cout << arr[i] << ' ';
cout << '\n';
return 0;
}
C++ sort(first_argument_is_more_back, second_argument_is_more_front)
最新推荐文章于 2023-03-17 18:11:56 发布