Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
27961 | 唐心 | 打字比赛 | C++ | Accepted | 10 MS | 892 KB | 1020 | 2022-06-12 18:47:29 |
#include<iostream> #include<cmath> #include<cstdio> #include<cstring> using namespace std; typedef struct Student { int no; int speek; double sage; }Student_s; void swp(Student_s *stua,Student_s *stub) { Student_s temp; temp = *stua; *stua = *stub; *stub = temp; } bool scmp(Student_s *stua,Student_s *stub) { if(stua->sage > stub->sage) return true; else if(stua->sage == stub->sage) { if(stua->no < stub->no) return true; else return false; } else return false; } int main() { int i,j,n,max; double age; Student_s stu[3001]; cin >> n; for(i = 0; i < n; i++) { stu[i].no = i+1; cin >> stu[i].speek; cin >> age; stu[i].sage = age * stu[i].speek/100; } for(i = 0; i < n-1; i++) { max = i; for(j = i+1; j < n ; j++) { if(scmp(&stu[j],&stu[max])) max = j; } swp(&stu[max],&stu[i]); } for(i = 0; i < n; i++) { cout << stu[i].no<<" "; printf("%.2lf\n",stu[i].sage); } return 0; }