更多"学生的记录由学号和成绩组成,N名学生的数据已在主函数中放入结构体数组s"的相关试题:
[简答题]学生的记录由学号和成绩组成,N名学生的数据已在主函数中放入结构体数组s中,请编写函数fun( ),该函数的功能是:把高于等于平均分的学生数据放在b所指的数组中,低于平均分的学生数据放在c所指的数组中,高于等于平均分的学生人数通过形参n传回,低于平均分的学生人数通过形参m传回,平均分通过函数值返回。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include <stdio.h>
#define N 12
typedef struct
{ char num[10];
double s;
} STREC;
double fun(STREC *a,STREC *b,STREC *c,int *n,int *m)
{
}
main( )
{
STREC s[N]={{"GA05",65},{"GA03",86},
{"GA02",76},{"GA04",95},{"GA01",93},
{"GA07",78},{"GA08",68},{"GA06",88},
{"GA09",60},{"GA11",54},{"GA12",56},
{"GA10",98}};
STREC h[N],l[N],t;
FILE *out;
int i,j,m,n;
double ave;
ave=fun(s,h,l,&n,&m);
printf("The %d student data which is higher than %7.3f:/n",n,ave);
for(i=0;i<n;i++)
printf("%s %4.lf/n",h[i].num,
h[i].s);
printf("/n");
printf("The %d Student data which iS lower than%7.3f:/n",m,ave);
for(i=0;i<m;i++)
printf("%s %4.1f/n",l[i].num, l[i].s);
printf("/n");
out=fopen("out26.d
[简答题]学生的记录由学号和成绩组成,N名学生的数据已在主函数中放入结构体数组S中,请编写函数fun,其功能是:把低于平均分的学生数据放入b所指的数组中,低于平均分的学生人数通过形参n传回,平均分通过函数值返回。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
试题程序:
#include<stdio.h>
#define N 8
typedef struct
char num[10];
double s;
STREC;
double fun(STREC*a,STREC*b,int*n)
void main( )
STREC s[N]="GA05",85,"GA03",76,"GA02",69,"GA04",85,"GA01",91,"GA07",72,"GA08",64,"GA06",87;
STREC h[N];
int i,n;
double ave;
ave=fun(s,h,&n);
printf("The%d student data which is lower
than%7.3f:/n"
n,ave);
for(i=0;i<n;i++)/*输出成绩低于平均值的学生记录*/
printf("%s%4.1f/n",h[i],num,h[i],s;
printf("/n");
[简答题]学生的记录由学号和成绩组成,N名学生的数据已在主函数中放入结构体数组s中,请编写函数fun( ),它的功能是:函数返回指定成绩的学生数据,指定的成绩在主函数中输入。若没找到指定的成绩,在结构体变量中给学号置空串,给成绩置-1,作为函数值返回。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include<stdio.h>
#include<stdlib.h>
#define N 16
typedef struct
{ char num[l0];
int s;
}STREC;
STREC fun(STREC *a,int b)
{
}
main( )
{
STREC s[N)={{"GA005",76},{"GA003",89},
{"GA002",64},{"GA004",75},{"GA001",88},
{"GA007",65},{"CA008",96},{"GA006",69},
{"GA015",85},{"GA013",78},{"GA012",62},
{"GA014",60},{"GA011",73},{"GA017",72},
{"GA018",98},{"GA016",94}};
STREC h;
int m;
int i,n;
FILE *out;
printf("The original data:/n");
for(i=0;i<N;i++)
{ if(i%4==0)
printf("/n");
/*每行输出4个学生记录*/
printf("%s%3d",s[i].num,s[i].s);
}
printf("/n/nEnter the score:");
scanf("%d",&m);
h=fun(s,m);
printf("The data:");
printf("/n%s %4d/n",h.mum,h.s);
printf("/n");
out=fopen("out24.dat","w");
h=fun(s,85);
fprintf(out,"%