题解 | 【模板】排序

【模板】排序

https://www.nowcoder.com/practice/40bf74658879460bbf5f1bfe772e8580

#include <iostream>

#include <algorithm>

#include <vector>

using namespace std;

int main() {

    //存数组个数

    int n;

    cin>>n;

   

    //存数组

    vector<int> a;

    int num;

    while(cin>>num){

        a.push_back(num);

    }

    //核心算法:排序

    sort(a.begin(),a.end());

    //打印

    for(int i=0;i<n-1;i++){

        cout<<a[i]<<" ";

    }

    cout<<a[n-1]<<endl;

}

// 64 位输出请用 printf("%lld")

全部评论

相关推荐

1jian10:48h没写面评会变成这样
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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