输入100名学生的学号,姓名,性别,住址及10门功课,且显示每个学生10门课的最低和最高分,还要显示每门课不及格的学生人数,,还输入一个学号就能显示该学生的信息
# include "stdio.h"# define N 100
# define M 10
struct student{
int iId;
char chName[15];
char chSex;
char chdizhi[15];
int fsore[M];
};
void fnmaxmin(struct student ststud[]);
void fndisp(struct student ststud[]);
void fnxinxi(struct student ststud[], int *num);
void main()
{
int i, j;
int sum;
struct student stperson[N];
printf("please input one hundred student's information:\n");
for(i=0; i<N; i++)
for(j=0; j<M; j++)
{
scanf("%d %s %s %s %d\n", stperson[i].iId, stperson[i].chName,
stperson[i].chSex, stperson[i].chdizhi, &stperson[i].fsore[j]);
}
fnmaxmin(stperson);
fndisp(stperson);
printf("please input a number:\n");
scanf("%d", &sum);
fnxinxi(stperson, &sum);
getch();
}
void fnmaxmin(struct student ststud[])
{
int i, j, imax=0, imin=0;
for(i=0; i<N; i++)
for(j=0; j<M; j++)
{
if(ststud[i].fsore[j]>ststud[i].fsore[imax])
imax=j;
printf("%d %s %s %s %d\n", ststud[i].iId, ststud[i].chName,
ststud[i].chSex, ststud[i].chdizhi,ststud[i].fsore[imax]);
}
for(i=0; i<N; i++)
for(j=0; j<M; j++)
{
if(ststud[i].fsore[j]<ststud[i].fsore[imin])
imin=j;
printf("%d %s %s %s %d\n", ststud[i].iId, ststud[i].chName,
ststud[i].chSex, ststud[i].chdizhi,ststud[i].fsore[imin]);
}
}
void fndisp(struct student ststud[])
{
int i,j, icount=0;
for(j=0; j<M; j++)
for(i=0; i<N; i++)
{
if(ststud[i].fsore[j]<60)
icount++;
printf("the %d course of not pass have %d students\n", j+1, icount);
}
}
void fnxinxi(struct student ststud[],int *num)
{
int i, j;
for(i=0; i<N; i++)
{
if(*num == ststud[i].iId)
break;
}
for(j=0; j<M; j++)
printf("%d %s %s %s %d\n", ststud[i].iId, ststud[i].chName,
ststud[i].chSex, ststud[i].chdizhi,ststud[i].fsore[j]);
}