2301_76234683 2023-03-10 17:53 采纳率: 0%
浏览 12

利用内置sort()函数排序 C++函数

Sort the given sequence in non-decreasing order.
Input
One line contains a sequence of no more than 105 integers.
Output
Print in one line a sequence of numbers in non-decreasing order.
按非递减顺序对给定序列进行排序。
输入
每行包含不超过105个整数的序列。
输出
在一行中打印非递减顺序的数字序列。
Sample
Input Output
4 1 4 8 6 6 5 1 4 4 5 6 6 8

  • 写回答

2条回答 默认 最新

  • 快乐鹦鹉 2023-03-10 18:30
    关注

    有啥问题啊,sort(a,a+n)这样子啊

    #include <iostream>
    using namespace std;
    #include<algorithm>
    int main()
    {
        int a[105];
        for(int i=0;i<105;i++)
            cin>>a[i];
        sort(a,a+105);
        for(int i=0;i<105;i++)
            cout<<a[i]<<" ";
    }
    
    
    评论 编辑记录

报告相同问题?

问题事件

  • 创建了问题 3月10日