8 条题解

  • 0
    @ 2022-7-10 19:31:47

    #include <stdio.h>

    #include

    #include

    #include

    #include

    #include <string.h>

    #include

    #include

    #include <math.h>

    using namespace std;

    #define LL long long

    const int N = 1e6 + 10;

    const int INF = 0x3f3f3f3f;

    int a[N];

    int main()

    {

    int n;
    
    cin >> n;
    
    for(int i = 1; i <= n; i++)
    
    cin >> a[i];
    
    sort( a+1, a+1+n); 
    

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

    // {

    // for(int j = 1; j <= n - i; j++)

    // {

    // if(a[j] > a[j+1])

    // {

    // int t = a[j];

    // a[j] = a[j+1];

    // a[j+1] = t;

    // }

    // }

    // }

    // for(int i = 1; i <= n ; i++)

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

    // for(int i = 1; i <= n ; i++)

    // {

    // int id = i;

    // for(int j = i + 1; j <= n ; j++)

    // {

    // if(a[j] < a[id])

    // id = j;

    // }

    // if(id != i)

    // {

    // int t = a[i];

    // a[i] = a[id];

    // a[id] = t;

    // }

    // }

    // for(int i = 1; i <= n ; i++)

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

    // for(int i = 2; i <= n ; i++)

    // for(int j = i - 1 ;j >= 1 && a[j] > a[j+1]; j--)

    // swap(a[j] , a[j+1]);

    for(int i = 1; i <= n ;i++)
    
    	cout << a[i] << " ";
    
    return 0;
    

    }

    信息

    ID
    1026
    时间
    1000ms
    内存
    32MiB
    难度
    6
    标签
    递交数
    535
    已通过
    171
    上传者