3 条题解

  • 0
    @ 2024-6-1 11:27:25
    #include<bits/stdc++.h>
    using namespace std;
    struct group{
          int id;
          int score;
    }g[105];
    bool cmp(group a,group b){
    	if(a.score==b.score)
    	return a.id<b.id;
    	else
    	return a.score>b.score;
    }
    int main(){
         int n;
         cin>>n;
         for(int i=0;i<n;i++)
    	 cin>>g[i].id>>g[i].score;
    	 sort(g,g+n,cmp);
     for(int i=0;i<n;i++)
     cout<<g[i].id<<" "<<g[i].score<<endl;
    	return 0;
    }
    
    
    • 0
      @ 2024-1-15 15:17:51
      #include<bits/stdc++.h>
      using namespace std;
      struct group{
            int id;
            int score;
      }g[105];
      bool cmp(group a,group b){
      	if(a.score==b.score)
      	return a.id<b.id;
      	else
      	return a.score>b.score;
      }
      int main(){
           int n;
           cin>>n;
           for(int i=0;i<n;i++)
      	 cin>>g[i].id>>g[i].score;
      	 sort(g,g+n,cmp);
       for(int i=0;i<n;i++)
       cout<<g[i].id<<" "<<g[i].score<<endl;
      	return 0;
      }
      
      • -1
        @ 2023-6-11 11:05:10

        image

        • 1

        等级考试C++16级_足球比赛排行榜

        信息

        ID
        639
        时间
        1000ms
        内存
        256MiB
        难度
        7
        标签
        (无)
        递交数
        16
        已通过
        10
        上传者