Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
20448 | 晁鑫 | 病人排队 | C++ | Accepted | 7 MS | 744 KB | 1069 | 2021-12-09 16:31:18 |
#include<iostream> #include<cmath> #include<cstdio> #include<cstring> using namespace std; typedef struct People { int no; char id[10]; int age; }People_s; void swp(People_s *stua,People_s *stub) { People_s temp; temp = *stua; *stua = *stub; *stub = temp; } bool scmp(People_s stua,People_s stub) { if(stua.age >= 60 || stub.age >= 60) { if(stua.age < stub.age) return true; else if(stua.age == stub.age) { if(stua.no > stub.no) return true; else return false; } else return false; } else if(stua.no > stub.no) return true; else return false; } int main() { int i,j,n; People stu[101] = {0},temp; cin >> n; for(i = 0; i < n; i++) { cin >> stu[i].id; cin >> stu[i].age; stu[i].no = i; } for(i = 1; i < n; i++) { temp = stu[i]; for(j = i; j > 0; j--) { if(scmp(stu[j-1],temp)) swp(&stu[j],&stu[j-1]); else break; } stu[j] = temp; } for(i = 0; i < n; i++) { cout << stu[i].id<<endl; } return 0; }