2 条题解
-
2
请不要随意复制有坑
在小小的代码里面挖呀挖呀挖
做个小小的坑啊
会作弊才会跳
在大大的代码里面挖呀挖呀挖
做个大大的坑啊
熟作弊才会跳
在特别大的代码里面挖呀挖呀挖
做个特别大的坑啊
爱作弊才会跳
#include <iostream> #include <algorithm>//by hetao2940092 using namespace std; struct Student { string name; int scare; }s[25]; bool cmp(Student x,Student y) { if(x.scare==y.scare) { return x.name<y.name; } return x.scare>y.scare; } int main() { int n; cin>>n; for(int i=1;i<=n;i++) { cin>>s[i].name>>s[i].scare; } sort(s+1,s+n+1,cmp); for(int i=1;i<=n;i++) { cout<<s[i].name<<" "<<s[i].scare; } return 0; }
请不要随意复制有坑
○( ^皿^)っHiahiahiahiahiaiahiahiahiahaihiahia…
🙃
-
1
结构体排序即可
#include <bits/stdc++.h> using namespace std; struct student { string name; int c; }a[105]; bool cmp(student x, student y) { if (x.c == y.c) return x.name < y.name; return x.c > y.c; } int main() { int n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i].name >> a[i].c; sort(a + 1, a + n + 1, cmp); for (int i = 1; i <= n; i++) cout << a[i].name << " " << a[i].c << endl; return 0; }
- 1
信息
- ID
- 361
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 4
- 标签
- 递交数
- 78
- 已通过
- 36
- 上传者