问答题 1.  学生的记录由学号和成绩组成,M名学生的数据已在主函数中放入结构体数组stu中,请编写函数proc(),它的功能是:把指定分数范围之外的学生数据放在b所指的数组中,分数范围之外的学生人数由函数值返回。
    例如,输入的分数是70和79,则应当把分数低于70和高于79的学生的数据输出,不包含70分和79分的学生的数据。主函数中把70放在low中,把79放在heigh中。
    注意:部分源程序给出如下。
    请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的花括号中填入所编写的若干语句。
    试题程序:
    #include <stdio.h>
    #define M 16
    typedef struct
    {
    char Bum[10];
    int s;
    STREC;
    int proc(STREC *a, STREC *b, int l, int h)
    {
    }
    void main()
    {
    STREC stu[M]={{"GA005",55},{"GA003",96},
    {"GA002",80},{"GA004",68},
    {"GA001",88},{"GA007",74},
    {"GA008",85},{"GA006",89},
    {"GA015",90},{"GA013",53},
    {"GA012",66},{"GA014",82},
    {"GA011",73},{"GA017",69},
    {"GA018",64},{"GA016",86}};
    STREC h[M];
    int i, n, low, heigh, t;
    printf{"Enter 2 integer number low & heigh:");
    scanf("%d%d", &low, &heigh);
    if(heigh<low)
    {
    t=heigh;
    heigh=low;
    low=t;
    }
    n=proe(stu, h, low, heigh);
    printf("The student's data out
    %d--%d:<n",low,heigh);
    for(i=0;i<n;i++)
    printf("%s%4d<n",h[i].num,h[i].s);
    //输出指定分数范围内的学生记录
    printf("<n");
    }
【正确答案】int proc(STREC *a, STREC *b, int l, int h)
   {
   int i, j=0;
   for(i=0;i<M;i++)
   if((a[i].s>=0&&a[i].s<1)||(a[i].s>h&&a[i].s<=100))  //通过if语句,来判断指定范围之外的数
   b[j++]=a[i];  //放到b数组中
   return j;   //最后把其个数返回给主函数
   }
【答案解析】 题目要求把指定范围之外的数放到数组b中,将每个学生的成绩与指定的成绩相比较,将符合条件的学生成绩放在数组b中,并将符合要求的学生个数返回给主函数。