请用C语言编写如下程序:有一个班的4个学生,有5门课

(1)求第一门课的平均分(2)找出两门以上课程不及格的学生,输出他们的学号和全部课程成绩及平均成绩(3)找出平均成绩在90分以上或全部成绩在85分以上的学生.分别编写个函数实现以上3个要求

#include "stdio.h"
struct student
{
char cord[10];
double cj[5];
double av;
int jg;
};
double input(student *st)
{
int i,j;
double s,s1;
s1=0;
for(i=0;i<4;i++)
{
s=0;
printf("输入第%d名学生的学号和5门成绩:",i+1);
scanf("%s",st[i].cord); 
for(j=0;j<5;j++)
{
scanf("%lf",&st[i].cj[j]);
s+=st[i].cj[j];
if(j==0)
s1+=st[i].cj[j];
}
st[i].av=s/5;
}
printf("\n\n");
return s1;
}
void jg2(student *st)
{
int i,j,k;
for(i=0;i<4;i++)
{
st[i].jg=0;
for(j=0;j<5;j++)
{
if(st[i].cj[j]>=60) 
st[i].jg+=1;
}
if(st[i].jg<3)
{
printf("%10s: ",st[i].cord);
for(k=0;k<5;k++)
{
printf("%3.0lf ",st[i].cj[k]);
}
printf("%3.2lf\n",st[i].av);
}
}
printf("\n\n");

void gf(student *st)
{
int i,j,k,m;
for(i=0;i<4;i++)
{
if(st[i].av>=90)
{
m=0;

}
else
{
for(j=0;j<5;j++)
{
if(st[i].cj[j]<85)
{
m=1;
break;
}
else
{
m=0;
}
}
}
if(m==0)
{
printf("%10s: ",st[i].cord);
for(k=0;k<5;k++)
{
printf("%3.0lf ",st[i].cj[k]);
}
printf("%3.2lf\n",st[i].av);
}
}
printf("\n\n");
}
int main()
{
double av1;
struct student st1[4];
av1=input(st1)/4;
printf("第一门课的平均分:%lf\n\n",av1);
printf("两门不及格:\n");
jg2(st1);
printf("平均成绩在90分以上或全部成绩在85分以上的学生:\n");
gf(st1);
}

温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-06-04
像这类的程序我做过很多都是采用模块化设计,需要可以给你,希望能了个帮助你
第2个回答  推荐于2017-12-16
int c[4][5];
int i,j,m,n;
...
/*行表示学生,列表示课程吧*/
c[1][0]=1;学号
c[1][1]=89;第一名课程成绩
。。。
m=0;
n=0;
for (i=1;i<5;i++)
m=m+c[i][1];
m=m/4;
printf("di yi men ke jun fen %d" ,m);

for (i=1;i<5;i++)
{
n=0;
for( j=1;i<=5;j++)
if (c[i][j]<60)n++
if (n>1)
{
for( j=0;i<=5;j++)
输出此人各科成绩
}
}
。。。本回答被网友采纳
相似回答