1080 MOOC期終成績 25分

2022-09-01 20:09:06 字數 1526 閱讀 5668

現在的問題是,每次考試都產生一張獨立的成績單。本題就請你編寫程式,把不同的成績單合為一張。

輸入格式

輸出格式

列印出獲得合格證書的學生名單。每個學生佔一行,格式為:

學生學號gp gmid-term gfinalg

如果有的成績不存在(例如某人沒參加期中考試),則在相應的位置輸出「−1」。輸出順序為按照總評分數(四捨五入精確到整數)遞減。若有並列,則按學號遞增。題目保證學號沒有重複,且至少存在1個合格的學生。

輸入樣例

6 6 7

01234 880

a1903 199

ydjh2 200

wehu8 300

dx86w 220

missing 400

ydhfu77 99

wehu8 55

ydjh2 98

dx86w 88

a1903 86

01234 39

ydhfu77 88

a1903 66

01234 58

wehu8 84

ydjh2 82

missing 99

dx86w 81

輸出樣例

missing 400 -1 99 99

ydjh2 200 98 82 88

dx86w 220 88 81 84

wehu8 300 55 84 84

將成績資訊依次輸入,用結構體儲存,結構體用map儲存,將id作為key

然後遍歷map每個元素,計算每個同學的總評成績,若不符合條件,總評g = 0

用乙個pair的vector取出map裡的資料,對這個vector自定義排序,再遍歷vector總評g>=60輸出即可

注意不能直接對map進行排序

#include#include#include#include#include#includeusing namespace std;

typedef struct nnode;

bool cmp(const pairl, const pairr) else

} int main()

while(m--)

while(n--)

for(auto it = stu.begin() ; it != stu.end() ; it ++)

else if(it -> second.gfinal >= it->second.gmid) it->second.g = it->second.gfinal;

}vector< pair>v(stu.begin(),stu.end());

sort(v.begin(),v.end(),cmp);

for(auto it = v.begin(); it!=v.end();it++)

}}

1080 MOOC期終成績

最後乙個測試點 6分 如果有的成績不存在 例如某人沒參加期中考試 則在相應的位置輸出 1 如果有的成績為0,則相應的位置應該輸出的是 0 注意不要也輸出成 1 了 額外輸入樣例 2 2 2 aaa 0 bbb 200 aaa 0 bbb 0 aaa 0 bbb 60 正確的輸出樣例 bbb 200 ...

PAT乙級 1080 MOOC期終成績

列印出獲得合格證書的學生名單。每個學生佔一行,格式為 學生學號 gp g mid term gfinal g 如果有的成績不存在 例如某人沒參加期中考試 則在相應的位置輸出 1 輸出順序為按照總評分數 四捨五入精確到整數 遞減。若有並列,則按學號遞增。題目保證學號沒有重複,且至少存在1個合格的學生。...

C語言程式設計 1080 MOOC期終成績

include include include include include include using namespace std struct node bool cmp const node a,const node b intmain for int i 0 i m i for int i...