1 条题解

  • 0
    @ 2025-11-30 16:26:39

    C++ :

    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    using namespace std;
    bool cmp(int a,int b)
    {
        return a>b;
    }
    int main()
    {
        int t,m,i,j,a[100];
        scanf("%d",&t);
        for(i=1; i<=t; i++)
        {
            int f=1;
            scanf("%d",&m);
            for(j=0; j<m; j++)
                scanf("%d",&a[j]);
            if(i%2==0)
                sort(a,a+m,cmp);
            else sort(a,a+m);
            for(j=0; j<m; j++)
    //                if(f)
    //            {
    //                printf("%d",a[j]);
    //                f=0;
    //            }
                printf("%d ",a[j]);
            printf("\n");
        }
        return 0;
    }
    
    
    • 1

    信息

    ID
    1243
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者