看板 YP93-312 關於我們 聯絡資訊
已經有下列的定義: #define UP 10 #define MAX 50 // 用在 struct struct_rec2 rec[MAX]; struct struct_rec { long int id; //學號 int course_no; //修課數目,0 -- 9 int score[UP]; //修課成績 }; struct struct_rec2 { struct struct_rec data; double avg; //平均成績 }; 請寫一個程式(包含若干個functions) 1.由鍵盤輸入學生的資料(st_rec的格式)至EOF(end of file)停止. 鍵盤的end of file mark 是Ctrl-Z(control Z). 輸入敘述之end of file測試: while ( (scanf("%ld", 學號)) != EOF){ 輸入其他資料 …………….. } 2.計算每個學生的平均成績 3.依據平均成績(高 ' 低)排序(sorting) 4.定名次(同分同名次)並列印.(印出 名次 學號 平均成績 修課數目(option) 修課成績(option) Option: 如何先將學生資料建成一個檔案(如同程式檔) std_data.txt 再用檔案轉向(redirecting input)由scanf() 函數讀取. 檔案格式: 學號 修課數目 成績1 成績2 成績3 ... 8923039 3 100 100 100 8823017 5 59 59 59 59 59 ----------------------------------------------------------------------------- 恩...我現在寫到剩下不知道修課成績要怎麼印出... 因為我想不出來要怎麼排序它..陣列沒法互換... 哪個好心人幫我想想吧.... -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.113.122.120