问题 问答题

学生的记录由学号和成绩组成,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");

答案

参考答案:

double fun(STREC*a,STREC*b,int*n)

{

int i,j=0;

dOuble av=0.0;

for(i=0;i<N;i++)

av=av+a[i],s;

av=av/N; /*求平均值*/

for(i=0;i<N;i++)

ifc a[i],s<av)b[j++]=a[i];

/*将低于平均值的学生记录存人结构体数组b中*/

*n=j; /*指针传回低于平均值的学生人数*/

return av; /*返回平均值*/

}

解析:

本题关键字有:结构体类型;循环语句;if条件语句;指针型变量。

[微分析]

本题先通过循环语句求出总分,进而求出平均分av,然后将分数低于平均分的学生记录存入数组b中,返回平均分。

单项选择题
阅读理解

Every day, life is made and lost. Every day, life goes on. Every day we experience some of the most important parts of life and may not even realize it: love, generosity, and perseverance. These values aren’t just important to us; they make the world what it is.

Scientists say that gravitaional(重力的)force makes the world turn, but some people say that love makes it go round. Love can be found anywhere: in families, friends, even complete strangers. Even if you can’t see it, you know it’s there.

Love may connect people all over the world, but what would the world be without generosity? Whether after a national disaster, or a school fund-raiser, one thing is certain----it is better to give than to receive. Generosity is found everywhere and whether it’s a large or small act, it makes a difference. Sometimes, though, it takes effort to be generous, which leads us to perseverance.

Founding a country, riding a bike, or finishing an essay, these are all finished with perseverance. Perseverance is the one thing that can help us achieve whatever we want. It is what helps scientists to discover cures for diseases, and athletes to become champions.

There is an infinite(无穷的) number of things we value, but without love, generosity and perseverance, we just don’t think that our life or the world would be the way it is.

1. The underlined word “it” in the second paragraph refers to “________”.

A. the world              B. gravitational force

C. value                    D. experience

2. To be generous, the author thinks________.

A. you needn’t make efforts                    B. you should be qualified

C. you should give all you have        D. you will find it good to give

3. Which of the following statements is TRUE according to the passage?

A. Perseverance is the only thing that can halp us to achieve success.

B. People don’t understand the life they are experiencing at all.

C. We can find love in complete strangers sometimes.

D. What the world is like depends on gravity and love.

4. What would be the best title for the passage?

A. Success and Failure                    B. Three Values

C. Endless Love                          D. Life Full of Hope