皮皮学,免费搜题
登录
logo - 刷刷题
搜题
【简答题】
以下程序用来计算任意个学生三门课的平均分并按平均分由高到低排序并打印输出。其中函数Input用来读取m个学生的信息,Total1函数用来计算总分和平均分,Sort函数按平均分由高到低排序,Print函数打印排序后的名次、、姓名、各科成绩及总分和平均分。请在主函数空白处填写适当内容将程序补充完整(分隔符请用英文输入法下的逗号填写不要有多余的空格,每一空白处占用一行填写后请换行)。#include #include struct student { long num; char name[20]; int Eng; int Com; int Mth;};void Input( struct student *p, int n);void Total1(struct student *p, int *psum, float *pave, int n);void Sort(struct student *p, int *psum, float *pave, int n);void Print(struct student *p, int *psum, float *pave, int n);main(){ struct student *p=NULL; int *psum=NULL; float *pave=NULL; int m; printf("请输入班级实际人数:\n"); scanf("%d",&m); p = ( struct student * )malloc( m*sizeof ( struct student )); psum = ( int * )malloc( m*sizeof ( int )); pave = ( float * )malloc( m*sizeof( float )); if( p ==NULL || psum == NULL || pave == NULL ) exit(0); Input( ); Total1( ); Sort( ); Print( );}void Input( struct student *p, int n){ int i; for(i=0;i num, (p+i)->name,&(p+i)->Eng, &(p+i)->Com, &(p+i)->Mth ); }}void Total1(struct student *p,int *psum, float *pave,int n){ int i; for( i = 0; I < n; i++ ) { psum[i] = 0; psum[i] = psum[i] + p[i].Eng+p[i].Com + p[i].Mth; pave[i] =( float )psum[i]/3; }}void Sort( struct student *p, int *psum, float *pave, int n){ int i,j,iterm; float fterm; struct student pterm; for ( i = 0; i < n-1; i++ ) { for ( j = i+1; j < n; j++ ) { if ( pave[i] < pave[j] ) { iterm = psum[i]; psum[i] = psum[j]; psum[j] = iterm; fterm = pave[i]; pave[i] = pave[j]; pave[j] = fterm; pterm = p[i]; p[i] = p[j]; p[j] = pterm; } } }}void Print( struct student *p, int *psum, float *pave, int n){ int i; printf("名次\t%\t姓名\t英语\t计算机\t数学\t总分\t平均分\n"); for ( i = 0; i < n; i++ ) { printf("%d\t%ld\t%s\t%d\t%d\t%d\t%d\t%.0f\n",i+1, (p+i)->num, (p+i)->name, (p+i)->Eng, (p+i)->Com,(p+i)->Mth, psum[i], pave[i] ); }}
手机使用
分享
复制链接
新浪微博
分享QQ
微信扫一扫
微信内点击右上角“…”即可分享
反馈
参考答案:
举一反三
【简答题】电力系统中,备用容量按存在形式可分为两种:()和()。
【单选题】As we all know, Asia is _____ Europe.
A.
four times as large as
B.
bigger than four times
C.
four times as much as
D.
four times the size as
【单选题】BIM的( )功能是BIM最重要的特征。
A.
协同合作
B.
三维可视化
C.
碰撞检查
D.
深化设计
【简答题】用A和B分别表示两个比较项,数量用n表示,is 用BE代替,提炼表示倍数的句型公式。 Asia is four times larger than Europe. 这里可以提炼出来的表示倍数句型公式是____________________________。
【单选题】含铁丰富的食物不包括
A.
B.
C.
D.
物血
E.
物肝
【单选题】Asia is ____ times as large as Europe.
A.
forty
B.
four
C.
fourteen
D.
/
【单选题】Asia is ______ Europe.
A.
four times larger as
B.
as four times large as
C.
larger four times than
D.
four times as large as
【单选题】含铁丰富的食物不包括
A.
牛奶
B.
蛋黄
C.
D.
动物血
E.
动物肝
【简答题】电力系统中,备用容量按存在形式可分为两种:即热备用和 。
【单选题】Asia is _______ Europe.
A.
as large as four times
B.
as four times large as
C.
four times as larger as
D.
four times as large as
相关题目:
参考解析:
知识点:
题目纠错 0
发布
创建自己的小题库 - 刷刷题