#包含?& ltstdio.h & gt
#包含?& ltstdlib.h & gt
#包含?& ltstring.h & gt
# defineN 5/*?學生人數?*/
# defineM 3/*?課程科目?*/
struct?學生/*?定義結構類型?*/
{
intnum
charname[20];
floatscore[M];
floatsum/*學生三門課的總成績*/
}?stu[5];
int?標準等級_輸入(無效)
{
int?我,?j;
for(I = 0;?我& ltn;?i++)
{
Printf("請輸入學號:");
scanf("%d ",& amp斯圖[我]。num);
Printf("請輸入學生姓名:");
scanf("%s ",& amp斯圖[我]。姓名);
for(j = 0;?j & ltm;?j++)
{
Printf("請輸入學生的%d課程成績:",?j+1);
scanf("%f ",& amp斯圖[我]。score[j]);
斯圖[我]。sum?+=?斯圖[我]。score[j];
}
}
Printf("成績信息輸入完成\ n \ n ");
回歸?0;
}
int?STDGRADE_course_aver(無效)
{
int?我;
for(I = 0;?我& ltn;?i++)
{
Printf("學號:%d,?名稱:%s,GPA: %f\n "?斯圖[我]。num,?斯圖[我]。姓名,?斯圖[我]。sum/(float)M);
}
Printf("完成平均成績輸出\ n \ n ");
回歸?0;
}
int?STDGRADE_sum_sort(void)
{
int?我,?j;
struct?學生?tmp
for(I = 0;?我& ltn;?i++)
{
memcpy(& amp;tmp,?& amp斯圖[我],?sizeof(struct?學生));
for(j = I+1;?j & ltn;?j++)
{
if(stu[j].sum?& gt?tmp.sum)
{
memcpy(& amp;斯圖[我],?& amp斯圖[j],?sizeof(struct?學生));
memcpy(& amp;斯圖[j],?& amptmp,?sizeof(struct?學生));
memcpy(& amp;tmp,?& amp斯圖[j],?sizeof(struct?學生));
}
}
}
回歸?0;
}
int?標準等級_輸出(無效)
{
int?我;
for(I = 0;?我& ltn;?i++)
{
Printf("學號:%d,?姓名:%s,總分:%f,\n "?斯圖[我]。num,?斯圖[我]。姓名,?斯圖[我]。sum);
}
回歸?0;
}
int?主()
{
STDGRADE _ input();
STD grade _ course _ aver();
STD grade _ sum _ sort();
STDGRADE _ output();
回歸?0;
}運行結果如下(VC6++執行結果)
以上,