需要iostream头文件
#include <stdio.h> #include <iostream> #include <algorithm> using namespace std; int main() { int a[5] = {1, 5, 4, 2, 3}; sort(a, a + 5, greater<int>()); //less<int>() for(int i = 0; i < 5; ++i) printf("%d ", a[i]); return 0; } //output //5 4 3 2 1
时间: 2024-10-13 02:38:36