题目内容

学生的记录由学号和成绩组成,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], t; FILE *out;
int i, j, n;
double ave;
ave=fun(s, h, &n);
printf("The %d student data which is lower than %7.3 f:\n", n, ave);
for(i=0; i<n; i++)
printf("%s %4.1f\n", h[i]. num, h[i].s);
printf("\n");
ut=fopen("out.dat", "W");
fprintf(out, "%d\n%7.3f\n", n, ave);
for(i=0; 2<n-1; i++)
for(j=i+1; j<n; j++)
if(h[i]. s>h[j].s)
{
t=h[i];
h[i]=h[j];
h[j]=t;
}
for(i=0; 2<n; i++)
fprintf(out, "%4.1f\n", h[i].s);
fclose(out);
}

查看答案
更多问题

What do the student information’ kits help students to find?

STANDARD CHARTERED BANK
Hong Kong Office
CREDIT ADVICE
Name: (1) Date: (2)
No. 100017 - 03011
Address: 91 Changdi Rd, Guangzhou,
Guangdong Province 510120
China
Particulars : (3)
Total Amount: (4)
(5)
() We have credited your account
() Please debit our account
() We enclose herewith our Cashier's Order/Demand Draft
() We have credited settle, bank a/c in your favor
Authorized Signature: (6)
(80)

明天是八月六(),是爷爷的生日。

看见我的手表没有? ()

答案查题题库