日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

PAT (Basic Level) Practice (中文)1015 德才论 (25 分)

發布時間:2024/5/6 编程问答 63 豆豆
生活随笔 收集整理的這篇文章主要介紹了 PAT (Basic Level) Practice (中文)1015 德才论 (25 分) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題目

宋代史學家司馬光在《資治通鑒》中有一段著名的“德才論”:“是故才德全盡謂之圣人,才德兼亡謂之愚人,德勝才謂之君子,才勝德謂之小人。凡取人之術,茍不得圣人,君子而與之,與其得小人,不若得愚人?!?/p>

現給出一批考生的德才分數,請根據司馬光的理論給出錄取排名。

輸入格式:
輸入第一行給出 3 個正整數,分別為:N(≤10?5?? ),即考生總數;L(≥60),為錄取最低分數線,即德分和才分均不低于 L 的考生才有資格被考慮錄取;H(<100),為優先錄取線——德分和才分均不低于此線的被定義為“才德全盡”,此類考生按德才總分從高到低排序;才分不到但德分到線的一類考生屬于“德勝才”,也按總分排序,但排在第一類考生之后;德才分均低于 H,但是德分不低于才分的考生屬于“才德兼亡”但尚有“德勝才”者,按總分排序,但排在第二類考生之后;其他達到最低線 L 的考生也按總分排序,但排在第三類考生之后。

隨后 N 行,每行給出一位考生的信息,包括:準考證號 德分 才分,其中準考證號為 8 位整數,德才分為區間 [0, 100] 內的整數。數字間以空格分隔。

輸出格式:
輸出第一行首先給出達到最低分數線的考生人數 M,隨后 M 行,每行按照輸入格式輸出一位考生的信息,考生按輸入中說明的規則從高到低排序。當某類考生中有多人總分相同時,按其德分降序排列;若德分也并列,則按準考證號的升序輸出。

輸入樣例:
14 60 80
10000001 64 90
10000002 90 60
10000011 85 80
10000003 85 80
10000004 80 85
10000005 82 77
10000006 83 76
10000007 90 78
10000008 75 79
10000009 59 90
10000010 88 45
10000012 80 100
10000013 90 99
10000014 66 60
輸出樣例:
12
10000013 90 99
10000012 80 100
10000003 85 80
10000011 85 80
10000004 80 85
10000007 90 78
10000006 83 76
10000005 82 77
10000002 90 60
10000014 66 60
10000008 75 79
10000001 64 90

C++實現

#include <iostream> #include <algorithm> #include <vector>using namespace std;struct student_score {int student_ID,Moral_score,Talent_score; };int cmp(struct student_score a, struct student_score b) {if ((a.Moral_score + a.Talent_score) != (b.Moral_score + b.Talent_score))return (a.Moral_score + a.Talent_score) > (b.Moral_score + b.Talent_score);else if (a.Moral_score != b.Moral_score)return a.Moral_score > b.Moral_score;elsereturn a.student_ID < b.student_ID; }int main() {int N, L, H;cin >> N >> L >> H;int total = N;struct student_score temp;vector<student_score> student[4];for (int i = 0; i < N; ++i) {cin >> temp.student_ID >> temp.Moral_score >> temp.Talent_score;if (temp.Moral_score < L || temp.Talent_score < L) total--;else if (temp.Moral_score >= H && temp.Talent_score >= H) student[0].push_back(temp);else if (temp.Moral_score >= H && temp.Talent_score < H) student[1].push_back(temp);else if (temp.Moral_score < H && temp.Talent_score < H && temp.Moral_score >= temp.Talent_score)student[2].push_back(temp);else student[3].push_back(temp);}cout << total << endl;for (int i = 0; i < 4; ++i) {sort(student[i].begin(), student[i].end(), cmp);for (int j = 0; j < student[i].size(); ++j) {cout << student[i][j].student_ID << ' ' << student[i][j].Moral_score << ' ' << student[i][j].Talent_score;cout << endl;}}return 0; }

總結

以上是生活随笔為你收集整理的PAT (Basic Level) Practice (中文)1015 德才论 (25 分)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。