题解 | #使用算法#

使用算法

https://www.nowcoder.com/practice/ba99206d258c4f96a69866bdf77162b4

#include <iostream>
#include <vector>
#include <algorithm>
// write your code here......

using namespace std;

int main() {

    vector<int> a;
    int num;
    for (int i = 0; i < 5; ++i)
    {
        cin >> num;
        a.push_back(num);
    }
    sort(a.begin(), a.end(), [](int a1, int a2){return a1 > a2;});
    for_each(a.begin(), a.end(), [](int i){cout << i << " ";});
    

    return 0;
}

按照题目要求使用sort和for_each算法

C++题解 文章被收录于专栏

记录在牛客网用C++刷题的题解思路

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-23 14:10
码农索隆:成年人最直白的答复:已读不回
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务