问题 问答题

下列给定程序中,函数fun()的功能是:对N名学生的学习成绩,按从高到低的顺序找出前m(m≤10)名学生来,并将这些学生数据存放在一个动态分配的连续存储区中,此存储区的首地址作为函数值返回。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。

试题程序: #include<stdio.h> #include<malloc.h> #include<string.h> #include<conio.h> #define N 10 typedef struct ss { char num[10]; int order; }STU; STU*fun(STU a[],int m) { STU b[N],*tt; int i,j,k; (1) ; for(i=0;i<N;i++) b[i]=a[i]; for(k=0;k<m;k++) { for(i=j=0;i<N;i++)if( (2) ) j=i; tt[k]=b[j]; b[j].order=0; } return (3) ; } outresult(STU a[],FILE*pf) { int i; for(i=0;i<N;i++)fprintf(pf,"No=%s Mark=%d\n" ,a[i].num,a[i].order);fprintf(pf,"\n\n"); } main() { STU[N]={{"A01",80},{"A02",79}, {"A03",66},{"A04",82},{"A05",87}, {"A06",93},{"A07",78},{"A08",60}, {"A09",85},{"A10",73}}; STU * p_order; int i,m; clrscr(); printf("* * * The Origial data * * *\n"); outresult(a,stdout); printf("\nGive the numeber of the students who have better score:"); scanf("%d",&m); while(m>10) {printf("\nGive the number of the studets who have better score:");scanf("%d",&m); } p_order=fun(a,m); printf("* * *THE RESULT* * *\n"); printf("* * * The top students * * *\n"); for(i=0;i<m;i++)printf("%s %d\n",p_order[i].num,p_order[i].order);free(p_order); }

答案

参考答案:

解析:(1)n=(STU*)malloc(sizeof(STU)*m) (2)b[i].order>b[j].order (3)tt 填空1:tt是结构体STU型指针,声明时并没有进行初始化,所以,需要使用malloc()函数动态申请存储空间。动态申请存储空间的大小取决于函数的形参m。填空2:按成绩高低找出前m名学生的方法是,先假设第一名学生成绩最高,依次与其他学生的成绩进行比较,如果出现成绩更高者,则认为这名学生成绩最高,全部比较完后找到成绩第一名的学生,存入指针tt所指的结构体空间中,同时将这名同学的成绩置0,这样在其他同学中找第一名就相当于找到所有同学中的第二名,依此类推,进行m次循环,找到前m名学生。填空3:题目要求函数值返回动态分配的存储区的首地址,所以返回指针tt。

阅读理解

FU Yuan has been left at home with his grandparents since he was one month old. His mom and dad left to work in Fujian Province. For the past eight years, Fu has only seen his parents three times although they send home 500 yuan every two or three months.

Fu Xiaoyu, 16, has had to live alone since her grandmother passed away three years ago. Her parents do not want to renounce their jobs at a clothing factory in Guangdong Province. Nor can they afford the cost of sending her to a school in the city where they work.

These are just two of the 29 kids that 16-year-olds Huang Ruoqing and Zhang Linna at Beijing No 4 High School talked with this summer in Guixiang Village in Sichuan Province.

What Huang and Zhang learned from their three-day visit shocked them. They wrote down all the kids’ stories in a moving 40-page essay filled with statistical charts.(统计表)

In the poor village with a population of 2,118 people, 582 adults have left to find work, leaving 156 children without parents. Among these so-called left-behind kids, 88 percent of them live with their grandparents, five percent live with uncles or aunts and seven percent have to live on their own.

To Huang and Zhang’s surprise, 80 percent of the children said they love going to school. Even

though, some children have to walk along the hilly roads for two hours to get there.

However, for this village’s students studying is not their first task. Housework, such as helping feed pigs or buffalos(水牛) and taking care of old grandparents, younger sisters or brothers, takes up a considerable amount of their time.

Despite having to work hard at home, over 65 percent of the young interviewees would prefer their parents’ stay away working rather than returning to live with them.

“These kids are understanding and considerate and know how important money is for their families. Their little wishes like having dinner with their parents inspire us never to take what we have had for granted,” Zhang said.

小题1:

Which of the following statements is NOT TRUE according to the passage?

A.Fu Xiaoyu’s parents can’t earn enough money to send her to school.

B.Huang Ruoqing and Zhang Linna talked with 29 children this summer during their research.

C.Some left-behind kids live with uncles, aunts, or grandparents and others live by themselves.

D.More than half of the left-behind kids prefer their parents’ staying away working.小题2:

It is implied but not directly stated that    

A.Fu Yuan’s parents send him 500 yuan every 2 or 3 months

B.Huang Ruoqing and Zhang Linna wrote an essay according to the left-behind kids’ stories

C.Many left-behind kids love studying and going to school in spite of many hardships

D.The time that the left-behind kids spend on housework is more than that on study小题3:

What’s the exact meaning of the underlined word “renounce”in the second paragraph?

A.Keep

B.continue

C.give up

D.get小题4:

Which of the following is the best title of the passage?

A.Kids Are Left Alone

B.The True Story of Home Alone

C.Kids Miss Parents

D.Parents and Kids

单项选择题