这是一个炒鸡水题,大佬们不要喷,但我确实容易忘。。。

#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
struct st{
    int n;
    float t;
};
struct st c[10];
bool duke(st a,st b)
{
    return a.t > b.t;
}
int main()
{
    int t;
    scanf("%d",&t);
    for(int i = 0;i < t;i ++)
    {
        scanf("%d%g",&c[i].n,&c[i].t);
    }
    sort(c,c+t,duke);
    for(int i = 0;i < t;i++)
    {
        printf("%d %g\n",c[i].n,c[i].t);
    }
    return 0;
}

虽然很简单,但是总是忘,所以在这里发布一下。#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
struct st{
    int n;
    float t;
};
struct st c[10];
bool duke(st a,st b)
{
    return a.t > b.t;
}
int main()
{
    int t;
    scanf("%d",&t);
    for(int i = 0;i < t;i ++)
    {
        scanf("%d%g",&c[i].n,&c[i].t);
    }
    sort(c,c+t,duke);
    for(int i = 0;i < t;i++)
    {
        printf("%d %g\n",c[i].n,c[i].t);
    }
    return 0;
}

 

相关文章:

  • 2022-01-06
  • 2022-01-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
猜你喜欢
  • 2021-09-23
  • 2021-04-19
  • 2021-09-25
  • 2021-06-26
  • 2022-12-23
相关资源
相似解决方案