竞赛
考级
求求了点个赞吧!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
༺ད六百六十六༒盐都不盐了ཌ༻
majmDZB
法兰西玫瑰
#include<bits/stdc++.h> using namespace std; struct j{ string s; int a; int b; int c; }; j w[1001],r[1001],t; int n,y=1,u=1; int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>t.s>>t.a>>t.b; if(t.a>60){ w[y]=t; y++; } else{ r[u]=t; u++; } }
雷霆的微光
很烫的凉水
回来看看
这里我们定义一个结构体,priority表示优先级(即是否是老人),name表示名字,age表示年龄,id表示输入顺序。 定义结构体排序函数,如果是老年人则先排序,60岁以下后排序。 接下来就是主函数部分,相信大家都看得懂。 如果对你有帮助就点一个赞吧!!!
织向黑夜的灯
潜龙暗虎
#include <iostream> #include <vector> #include <string> #include <algorithm> using namespace std; struct Person { string name; int age; int registrationOrder; }; int main() { int n; cin >> n; }
178****4954
#include <bits/stdc++.h> using namespace std; struct Node{ string name; int age,id; bool pd; }a[201]; bool cmp(Node a,Node b) { if(a.pd!=b.pd) return a.pd>b.pd; return a.id<b.id; } int main(){ int n; cin>>n; for(int i=0;i<n;i++) { cin>>a[i].name>>a[i].age>>a[i].id; if(a[i].age>60) a[i].pd=true; else a[i].pd=false; } sort(a,a+n,cmp); for(int i=0;i<n;i++) cout<<a[i].name<<endl; return 0; }
Voldemort
准
李赛科
枫岚
zsy
提交答案之后,这里将显示提交结果~