038 白给的list排序

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <list>
using namespace std;
int main()
{
    double a[] = { 1.2,3.4,9.8,7.3,2.6 };
    list<double> lst(a, a + 5);
    lst.sort(greater<double>());  //倒序排序

    for (list<double>::iterator i = lst.begin(); i != lst.end(); ++i)
        cout << *i << ",";
    return 0;
}
posted @ 2022-02-28 15:26  icefield817  阅读(60)  评论(0编辑  收藏  举报