3 条题解

  • 1
    @ 2025-9-28 13:59:20
    #include <iostream>
    #include <algorithm>
    using namespace std;
    int a[5];
    int main()
    {
    	scanf("%d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &a[4]);
    	sort(a, a + 5);
    	printf("%d %d %d %d %d", a[4], a[3], a[2], a[1], a[0]);
    	return 0;
    }
    • 0
      @ 2022-12-10 18:08:53

      浅写cmp函数 话不多说上代码

      #include<bits/stdc++.h>//万能头
      using namespace std;
      int a[6];//数组
      bool cmp(int a,int b){//cmp函数,让数组从大到小排序
      	return a>b;
      }
      int main(){
      	for(int i=1;i<=5;i++)cin>>a[i];//输入
      	sort(a+1,a+6,cmp);//sort函数
      	for(int i=1;i<=5;i++)cout<<a[i]<<" ";//输出
      	return 0;
      }
      

      痛哭——添胜第三周没做完就到时间了 麻烦点赞 欢迎来luogu找我玩!

      • -1
        @ 2025-7-18 14:02:24

        装个逼

        1.vector

        #include<bits/stdc++.h>
        using namespace std;
        const int N=1e5+5,INF=0x3f3f3f3f;
        typedef long long LL;
        #define endl '\n'
        int main(){
        	ios::sync_with_stdio(false);
        	cin.tie(nullptr);cout.tie(nullptr);
        	vector<int>a(5);
        	for(int i=0;i<=4;i++)cin>>a[i];
        	sort(a.begin(),a.end());
        	for(int i=4;i>=0;i--)cout<<a[i]<<" ";
        	return 0;
        }
        

        2.@杨隽芮如果不反序输出那么这个送给你

        #include<bits/stdc++.h>
        using namespace std;
        const int N=1e5+5,INF=0x3f3f3f3f;
        typedef long long LL;
        #define endl '\n'
        int main(){
        	ios::sync_with_stdio(false);
        	cin.tie(nullptr);cout.tie(nullptr);
        	vector<int>a(5);
        	for(int i=0;i<=4;i++)cin>>a[i];
        	sort(a.begin(),a.end(),greater<int>());
        	for(int i=0;i<=4;i++)cout<<a[i]<<" ";
        	return 0;
        }
        

        3.杨隽芮:一定要用函数

        马睿:行

        #include<bits/stdc++.h>
        using namespace std;
        const int N=1e5+5,INF=0x3f3f3f3f;
        typedef long long LL;
        #define endl '\n'
        int main(){
          ios::sync_with_stdio(false);
          cin.tie(nullptr);cout.tie(nullptr);
          vector<int>a(5);
          for(int i=0;i<=4;i++)cin>>a[i];
          sort(a.begin(),a.end(),[&](const int& x,const int& y){
          	return x>y;
          });
          for(int i=0;i<=4;i++)cout<<a[i]<<" ";
          return 0;
        }
        

        看得方便多了

        • 1

        信息

        ID
        1500
        时间
        1000ms
        内存
        256MiB
        难度
        3
        标签
        递交数
        132
        已通过
        71
        上传者