C語言上機題庫百科園第八章!南信大!_第1頁
C語言上機題庫百科園第八章!南信大!_第2頁
C語言上機題庫百科園第八章!南信大!_第3頁
C語言上機題庫百科園第八章!南信大!_第4頁
C語言上機題庫百科園第八章!南信大!_第5頁
已閱讀5頁,還剩19頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領

文檔簡介

1、第八章以下敘述中正確的是()若有以下語句typedefstruct Sint g; char h;T;A.可用T定義結(jié)構(gòu)體變量B.T是struct S類型的變量C.可用S定義結(jié)構(gòu)體變量D.S是struct類型的變量當定義一個結(jié)構(gòu)體變量時,系統(tǒng)分配給它的內(nèi)存是( )。A.結(jié)構(gòu)體中最后一個成員所需內(nèi)存量B.成員中占內(nèi)存量最大的容量C.結(jié)構(gòu)體中第一個成員所需內(nèi)存量D.各成員所需內(nèi)存量的總和若有以下定義:struct linkint data;struct link *next;a,b,c,*p,*q;且變量a和b之間已有如下圖所示的鏈表結(jié)構(gòu),若指針p指向a,指針q指向c。則能把c插入到a和b之間形成

2、新的鏈表的語句是( )A.p->next=&c;q->next=p->next;B.p.next=q;q.next=p.next;C.p->next=q; q->next=&b;D.a.next=c; c.next=b;/*N名學生的成績已在主函數(shù)中放入一個帶頭節(jié)點的鏈表結(jié)構(gòu)中,h指向鏈表的頭節(jié)點。請編寫函數(shù)fun,它的功能是:求出平均分,由函數(shù)值返回。 例如,若學生的成績是85,76,69,91,72,64,87,則平均分應當是78.625。 注意:部分源程序給出如下。請勿改動main函數(shù)和其他函數(shù)中的任何內(nèi)容,僅在函數(shù)fun的花括號中填入所編寫

3、的若干語句。試題程序:*/ #include<stdlib.h>#include<stdio.h>#define N 8struct slist double s; struct slist *next;typedef struct slist STREC;double fun(STREC *h)/*Begin*/*End*/STREC *creat(double *s) /*創(chuàng)建鏈表*/ STREC *h,*p,*q; int i=0; h=p=( STREC*)malloc(sizeof(STREC); p->s=0; while(i<N) q=( ST

4、REC*)malloc(sizeof(STREC); q->s=si;i+;p->next=q;p=q; p->next=0; return h;outlist(STREC *h) STREC *p; p=h->next; printf("head "); do printf("->%4.1f ",p->s); p=p->next; /*輸出各成績*/ while(p!=NULL); printf("nn");void main() FILE *wf; double sN=85,76,69,8

5、5,91,72,64,87,ave; STREC *h; h=creat(s); outlist(h); ave=fun(h); printf("ave=%6.3fn ",ave);/*/ wf=fopen("debugout25.dat","w"); fprintf(wf,"%6.3fn",ave); fclose(wf);/*/【參考代碼】 double av=0.0; STREC *p=h->next; /*p直接指向"頭節(jié)點"的下一個節(jié)點,即第一個成績*/ while(p!=NUL

6、L) av=av+p->s; /*求總分數(shù)*/ p=p->next; return av/N; /*返回平均值*/ /*學生的記錄由學號和成績組成,N名學生的數(shù)據(jù)已在主函數(shù)中放入結(jié)構(gòu)體數(shù)組s中,請編寫函數(shù)fun,該函數(shù)的功能是:把高于等于平均分的學生數(shù)據(jù)放在b所指的數(shù)組中,高于等于平均分的學生人數(shù)通過形參n傳回,平均分通過函數(shù)值返回。注意:部分源程序給出如下。請勿改動main函數(shù)和其他函數(shù)中的任何內(nèi)容,僅在函數(shù)fun的花括號中填入所編寫的若干語句。試題程序: */#include <stdio.h># define N 12typedef struct char num

7、10; double s; STREC;double fun (STREC *a,STREC *b, int *n)/*Begin*/*End*/void main() FILE *wf; STREC sN="GA05",85,"GA03",76,"GA02",69,"GA04",85, "GA01",91,"GA07",72,"GA08",64,"GA06",87, "GA09",60,"GA11&quo

8、t;,79,"GA12",73,"GA10",90; STREC hN,t; int i,j,n; double ave; ave=fun(s,h,&n); printf("The %d student data which is higher than %7.3f:n",n,ave); for(i=0; i<n; i+)printf("%s %4.1fn",hi.num,hi.s); printf("n"); for(i=0; i<n-1; i+) for(j=i+1;j&

9、lt;n;j+) if(hi.s<hj.s) t=hi;hi=hj;hj=t; /*分數(shù)從高到低排列*/*/ wf=fopen("debugout29.dat","w"); fprintf(wf, "%d %7.3fn",n,ave); for(i=0; i<n; i+) fprintf(wf, "%s %4.1fn",hi.num,hi.s); fclose(wf);/*/【參考代碼】 int i; double av=0.0; *n=0; for(i=0;i<N;i+) av=av+ai.s;

10、 av=av/N; /*求平均值*/ for(i=0;i<N;i+) if(av<=ai.s) b*n=ai;*n=*n+1; /*將高于等于平均分的學生存入b所指存儲單元中,并統(tǒng)計人數(shù)*/ return av; /*返回平均分*/ /*學生的記錄由學號和成績組成,N名學生的數(shù)據(jù)已在主函數(shù)中放入結(jié)構(gòu)體數(shù)組s中,請編寫函數(shù)fun,它的功能是:把指定分數(shù)范圍內(nèi)的學生數(shù)據(jù)放在b所指的數(shù)組中,分數(shù)范圍內(nèi)的學生人數(shù)由函數(shù)值返回。例如,輸入的分數(shù)是60和69,則應當把分數(shù)在60到69的學生數(shù)據(jù)進行輸出,包含60分和69分的學生數(shù)據(jù)。主函數(shù)中把60放在low中,把69放在heigh中。注意:部分

11、源程序給出如下。請勿改動main函數(shù)和其他函數(shù)中的任何內(nèi)容,僅在函數(shù)fun的花括號中填入所編寫的若干語句。試題程序: */#include <stdio.h>#define N 16typedef struct char num10; int s ;STREC;int fun (STREC *a, STREC *b, int l, int h )/*Begin*/*End*/void main () FILE *wf; STREC sN= "GA005",85,"GA003",76,"GA002",69,"GA0

12、04",85, "GA001",96,"GA007",72,"GA008",64,"GA006",87, "GA015",85,"GA013",94,"GA012",64,"GA014",91, "GA011",90,"GA017",64,"GA018",64,"GA016",72; STREC hN,tt; int i, j,n, low, he

13、igh, t; printf("Enter 2 integer number low & heigh: "); scanf("%d%d",&low,&heigh); if(heigh<low) t=heigh;heigh=low; low=t; n=fun(s,h,low, heigh); printf("The student 's data between %d-%d:n ",low, heigh); for(i=0;i<n;i+) printf("%s %4dn "

14、,hi.num, hi.s); /*輸出指定分數(shù)范圍內(nèi)的學生記錄*/ printf("n ");/*/ n=fun(s,h,80,98); for(i=0;i<n-1;i+) /*分數(shù)在8098之間的學生記錄按分數(shù)從低到高排列*/ for(j=i+1;j<n;j+) if(hi.s>hj.s) tt=hi;hi=hj;hj=tt; wf=fopen("debugout26.dat","w"); for(i=0;i<n;i+) fprintf(wf, "%s %4dn",hi.num, hi.

15、s); fclose(wf);/*/【參考代碼】 int i,j=0; for(i=0;i<N;i+) if(ai.s>=l&&ai.s<=h) /*將分數(shù)高于l,低于h的學生記錄存于結(jié)構(gòu)體數(shù)組b中*/ bj+=ai; return j; /*返回分數(shù)范圍內(nèi)的學生人數(shù)*/ /*某學生的記錄由學號、8門課成績和平均分組成,學號和8門課的成績已在主函數(shù)中給出。請編寫fun函數(shù),它的功能是:求出該學生的平均分放在記錄的ave成員中。請自己定義正確的形參。例如,若學生的成績是85.5,76,69.5,85,91,72,64.5,87.5,則他的平均分應當是78.875

16、。 注意:部分源程序給出如下。請勿改動main函數(shù)和其他函數(shù)中的任何內(nèi)容,僅在函數(shù)fun的花括號中填入所編寫的若干語句。試題程序: */#include <stdio.h>#define N 8typedef struct char num10; double sN; double ave; STREC;void fun(STREC *p)/*Begin*/*End*/void main() FILE *wf; STREC s= "GA005 ",85.5,76,69.5,85,91,72,64.5,87.5; int i; fun(&s); print

17、f("The %s's student data:n", s.num); /*輸出學號*/ for(i=0;i<N;i+) printf("%4.1fn",s.si); /*輸出各科成績*/ printf("nave=%7.3fn", s.ave); /*輸出平均分*/*/ wf=fopen("debugout24.dat","w"); fprintf(wf,"ave=%7.3fn", s.ave); fclose(wf);/*/【參考代碼】int i; p-&

18、gt;ave=0.0; for(i=0;i<N;i+) p->ave=p->ave+p->si; /*求各門成績的總和*/ p->ave=p->ave/N; /*求平均分*/ /*已知學生的記錄由學號和學習成績構(gòu)成,N名學生的數(shù)據(jù)已存入a結(jié)構(gòu)體數(shù)組中。請編寫函數(shù)fun,該函數(shù)的功能是:找出成績最低的學生記錄,通過形參返回主函數(shù)(規(guī)定只有一個最低分)。已給出函數(shù)的首部,請完成該函數(shù)。注意:部分源程序給出如下。請勿改動main函數(shù)和其他函數(shù)中的任何內(nèi)容,僅在函數(shù)fun的花括號中填入所編寫的若干語句。試題程序:*/#include<stdio.h>#i

19、nclude<string.h>#include<stdlib.h>#define N 10typedef struct ss char num10; int s; STU;fun(STU a, STU *s)/*Begin*/*End*/void main() FILE *wf; STU aN= "A01",81, "A02",89, "A03",66, "A04",87, "A05",77, "A06",90, "A07",79

20、, "A08",61, "A09",80, "A10",71,m; int i; printf("*The original data*n"); for(i=0;i<N;i+) printf("No=%s Mark=%dn", ai.num,ai.s); fun(a,&m); printf("*THE RESULT*n"); printf("The lowest :%s, %dn",m.num,m.s);/*/ wf=fopen("

21、debugout28.dat","w"); fprintf(wf,"%s %dn",m.num,m.s); fclose(wf);/*/【參考代碼】 int i; *s=a0; /*先認為第1個值最小*/ for(i=0;i<N;i+) /*如果在循環(huán)的過程中,發(fā)現(xiàn)比第1個值更小的則賦給*s*/ if(s->s>ai.s) *s=ai; /*學生的記錄由學生和成績組成,N名學生的數(shù)據(jù)已在主函數(shù)中放入結(jié)構(gòu)體數(shù)組s中,請編寫函數(shù)fun,其功能是:把分數(shù)最低的學生數(shù)據(jù)放在h所指的數(shù)組中。注意:分數(shù)最低的學生可能不止一個,函數(shù)返回分數(shù)

22、最低的學生的人數(shù)。注意:部分源程序給出如下。請勿改動main函數(shù)和其他函數(shù)中的任何內(nèi)容,僅在函數(shù)fun的花括號中填入所編寫的若干語句。試題程序:*/#include <stdio.h># define N 16typedef struct char num10; int s; STREC;int fun (STREC *a,STREC *b)/*Begin*/*End*/void main() STREC sN="GA05",85,"GA03",76,"GA02",69,"GA04",85,"

23、GA01",91,"GA07",72,"GA08",64, "GA06",87,"GA015",85,"GA013",91,"GA012",64,"GA014",91,"GA011",91,"GA017",64,"GA018",64,"GA016",72; STREC hN; int i,n; FILE *out; n=fun(s,h); printf("T

24、he %d lowest score:n",n); for(i=0;i<n;i+) printf("%s %4dn",hi.num,hi.s); printf("n"); /*/ out=fopen("debugout22.dat","w"); fprintf(out,"%dn",n); for(i=0;i<n;i+) fprintf(out,"%4dn",hi.s); fclose(out); /*/【參考代碼】 int i,j=0,n=0,min;

25、min=a0.s; for(i=0;i<N;i+) if(ai.s<min) min=ai.s; for(i=0;i<N;i+) if(ai.s=min) *(b+j)=ai;j+;n+; return n; /*學生的記錄由學號和成績組成,N名學生的數(shù)據(jù)已在主函數(shù)中放入結(jié)構(gòu)體數(shù)組s中,請編寫函數(shù)fun,它的功能是:把低于平均分的學生數(shù)據(jù)放在b所指的數(shù)組中,低于平均分的學生人數(shù)通過形參n傳回,平均分通過函數(shù)值返回。注意:部分源程序給出如下。請勿改動main函數(shù)和其他函數(shù)中的任何內(nèi)容,僅在函數(shù)fun的花括號中填入所編寫的若干語句。試題程序: */#include<stdi

26、o.h>#define N 8typedef struct char num10; double s; STREC;double fun(STREC *a, STREC *b, int *n)/*Begin*/*End*/void main() FILE *wf; STREC sN= "GA05 ",85, "GA03 ",76, "GA02 ",69, "GA04 ",85, "GA01 ",91, "GA07 ",72, "GA08 ",64,

27、"GA06 ",87; STREC hN; 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.1fn ",hi.num,hi.s); printf("n ");/*/ wf=fopen("debugout30.dat",&quo

28、t;w"); fprintf(wf, "%d %7.3fn",n,ave); for(i=0;i<n;i+) fprintf(wf, "%s %4.1fn",hi.num,hi.s); fclose(wf);/*/【參考代碼】 int i,j=0; double av=0.0; for(i=0;i<N;i+) av=av+ai.s; av=av/N; /*求平均值*/ for(i=0;i<N;i+) if(ai.s<av) bj+=ai; /*將低于平均值的學生記錄存入結(jié)構(gòu)體b中*/ *n=j; /*指針傳回低于平均值的

29、學生人數(shù)*/ return av; /*返回平均值*/ /*學生的記錄由學號和成績組成,N名學生的數(shù)據(jù)已在主函數(shù)中放入結(jié)構(gòu)體數(shù)組s中,請編寫函數(shù)fun,它的功能是:把分數(shù)最高的學生數(shù)據(jù)放在b所指的數(shù)組中,注意:分數(shù)最高的學生可能不止一個,函數(shù)返回分數(shù)最高的學生的人數(shù)。 注意: 部分源程序在文件PROG1.C中。 請勿改動主函數(shù)main和其它函數(shù)中的任何內(nèi)容,僅在函數(shù)fun的花括號中填入 你編寫的若干語句。 給定源程序: */#include <stdio.h> #define N 16 typedef struct char num10; int s; STREC; int fun

30、( STREC *a, STREC *b ) /*Begin*/ /*End*/ int main() STREC sN="GA05",85,"GA03",76,"GA02",69,"GA04",85, "GA01",91,"GA07",72,"GA08",64,"GA06",87, "GA015",85,"GA013",91,"GA012",64,"GA014&qu

31、ot;,91, "GA011",77,"GA017",64,"GA018",64,"GA016",72; STREC hN; int i,n;FILE *out ; n=fun(s,h); printf("The %d highest score :n",n); for(i=0;i<n; i+) printf("%s %4dn",hi.num,hi.s); printf("n"); out = fopen("debugout.dat&quo

32、t;,"w"); for(i=0;i<n; i+) fprintf(out, "%s %dn",hi.num,hi.s); fclose(out);return 0; /*學生的記錄由學號和成績組成,N名學生的數(shù)據(jù)已在主函數(shù)中放入結(jié)構(gòu)體數(shù)組s中,請編寫函數(shù)fun,它的功能是:按分數(shù)的高低排列學生的記錄,高分在前。注意:部分源程序給出如下。請勿改動main函數(shù)和其他函數(shù)中的任何內(nèi)容,僅在函數(shù)fun的花括號中填入所編寫的若干語句。試題程序: */#include <stdio.h>#define N 16typedef struct cha

33、r num10; int s ;STREC;void fun (STREC a)/*Begin*/*End*/void main () FILE *wf; STREC sN= "GA005",85,"GA003",76,"GA002",69,"GA004",85, "GA001",91,"GA007",72,"GA008",64,"GA006",87, "GA015",85,"GA013",91,

34、"GA012",64,"GA014",91, "GA011",66,"GA017",64,"GA018",64,"GA016",72; int i; fun(s); printf("The data after sorted :n"); for (i=0; i<N; i+) printf("%s %4dn",si.num,si.s); /*/ wf=fopen("debugout23.dat","w&

35、quot;); for (i=0; i<N; i+) fprintf(wf,"%s %4dn",si.num,si.s); fclose(wf);/*/【參考代碼】 int i,j; STREC t; for(i=1;i<N;i+) for(j=0;j<N-1;j+) if(aj.s<aj+1.s) t=aj;aj=aj+1;aj+1=t; /*學生的記錄由學號和成績組成,N名學生的數(shù)據(jù)已在主函數(shù)中放入結(jié)構(gòu)體數(shù)組s中,請編寫函數(shù)fun,它的功能是:把分數(shù)最高的學生數(shù)據(jù)放在h所指的數(shù)組中。注意:分數(shù)高的學生可能不只一個,函數(shù)返回分數(shù)最高學生的人數(shù)。注意

36、:部分源程序給出如下。請勿改動main函數(shù)和其他函數(shù)中的任何內(nèi)容,僅在函數(shù)fun的花括號中填入所編寫的若干語句。試題程序: */#include <stdio.h>#define N 16typedef struct char num10; int s ;STREC;int fun (STREC *a, STREC *b)/*Begin*/*End*/void main () FILE *wf; STREC sN="GA005",85,"GA003",76,"GA002",69,"GA004",85,

37、"GA001",91,"GA007",72,"GA008",64,"GA006",87, "GA015",85,"GA013",91,"GA012",64,"GA014",91, "GA011",66,"GA017",64,"GA018",64,"GA016",72; STREC hN; int i, n; n=fun(s,h); printf("

38、The %d highest score :n",n); for (i=0; i<n; i+) printf("%s %4dn ",hi.num,hi.s); /*輸出最高分學生的學號和成績*/ printf("n");/*/ wf=fopen("debugout27.dat","w"); fprintf(wf, "%dn",n); for (i=0; i<n; i+) fprintf(wf,"%s %4dn",hi.num,hi.s); fclose(

39、wf);/*/【參考代碼】 int i,j=0,max=a0.s; for(i=0;i<N;i+) if(max<ai.s) max=ai.s;/*找出最大值*/ for(i=0;i<N;i+) if(max=ai.s) bj+=ai; /*找出成績與max相等的學生的記錄,存入結(jié)構(gòu)體b中*/ return j; /*返回最高成績的學生人數(shù)*/ /*下列給定程序中,函數(shù)fun的功能是:對N名學生的學習成績,按從高到低的順序找出前m(m<=10)名學生,并將這些學生數(shù)據(jù)存放在一個動態(tài)分配的連續(xù)存儲區(qū)中,此存儲區(qū)的首地址作為函數(shù)值返回。 請改正程序中的錯誤,使它能得出正確的

40、結(jié)果。 注意:不要改動main函數(shù),不得增行或刪行,也不得更改程序的結(jié)構(gòu)。 試題程序:*/ #include <stdlib.h>#include <string.h>#include <stdio.h>#include <malloc.h>#define N 10typedef struct ss char num10; int s; STU;STU *fun(STU a, int m) STU bN,*t; int i, j,k;/*ERROR*/ *t=calloc(m,sizeof(STU); for(i=0;i<N;i+) bi=

41、ai; for(k=0;k<m;k+) for (i=j=0;i<N;i+) if(bi.s>bj.s) j=i;/*ERROR*/ tk.num=bj.num; tk.s=bj.s; bj.s=0; return t;outresult(STU a,FILE *pf) int i; for(i=0;i<N;i+) fprintf(pf, "No=%s Mark=%dn ",ai.num, ai.s); fprintf(pf, "nn ");void main() STU aN= "A01 ",81, &quo

42、t;A02 ",89, "A03 ",66, "A04 ",87, "A05 ",77, "A06 ",90, "A07 ",79, "A08 ",61, "A09 ",80, "A10 ",71; STU *pOrder; int i, m; printf("*THE RESULT*n"); outresult(a,stdout); printf("nGive the number of the

43、 students who have better score: "); scanf("%d",&m); while(m>10) printf("nGive the number of the students who have better score: "); scanf("%d",&m); pOrder=fun(a,m); printf("* THE RESULT*n"); printf("The top :n"); for(i=0;i<m;i+) p

44、rintf("%s %dn",pOrderi.num, pOrderi.s); free(pOrder); 【參考答案】t=calloc(m,sizeof(STU);【參考答案】tk=bj;/*下列給定程序的功能是:建立一個帶頭節(jié)點的單向鏈表,并用隨機函數(shù)為各節(jié)點數(shù)據(jù)域賦值。函數(shù)fun的作用是求出單向鏈表節(jié)點(不包括頭節(jié)點)數(shù)據(jù)域中的最大值,并且作為函數(shù)值返回。請改正函數(shù)fun中的錯誤,使它能得出正確的結(jié)果。注意:不要改動main函數(shù),不得增行或刪行,也不得更改程序的結(jié)構(gòu)。試題程序: */#include <stdio.h>#include <stdlib

45、.h>typedef struct aa int data; struct aa *next; NODE;fun (NODE *h) int max=-1; NODE *p;/*ERROR*/ p=h; while(p) if(p->data>max) max=p->data;/*ERROR*/ p->next=h; return max;outresult(int s, FILE *pf) fprintf(pf, "nThe max in link :%dn",s);NODE *creatlink(int n, int m) NODE *h,

46、*p,*s; int i; h=p=(NODE *)malloc(sizeof(NODE); h->data=9999; for(i=1;i<=n;i+) s=(NODE *) malloc(sizeof(NODE); s->data=rand()%m; s->next=p->next; p->next=s; p=p->next; p->next=NULL; return h;outlink(NODE *h,FILE *pf) NODE *p; p=h->next; fprintf(pf, "n The LIST :nn HEAD

47、"); while(p) fprintf(pf, "->%d",p->data); p=p->next; fprintf(pf, "n");main() NODE *head; int m; head=creatlink(12,100); outlink(head,stdout); m=fun(head); printf("nThe RESULT :n"); outresult(m,stdout);【參考答案】p=h->next;【參考答案】p=p->next;/*下列給定程序中的函數(shù)Creat

48、link的功能是:創(chuàng)建帶頭節(jié)點的單向鏈表,并為各節(jié)點數(shù)據(jù)域賦0到m-1的值。 請改正函數(shù)Creatlink中的錯誤,使它能得出正確的結(jié)果。 注意:不要改動main函數(shù),不得增行或刪行,也不得更改程序的結(jié)構(gòu)。 試題程序: */#include <stdio.h>#include <stdlib.h>typedef struct aa int data; struct aa *next; NODE;NODE *Creatlink(int n, int m) NODE *h=NULL,*p,*s; int i; s=(NODE *)malloc(sizeof(NODE); h

49、=s;/*ERROR*/ p->next=NULL; for(i=1;i<n;i+) s=(NODE *) malloc(sizeof(NODE);/*ERROR*/ s->data=rand()%m; s->next=p->next;p->next=s; p=p->next; s->next=NULL;/*ERROR*/ return p;outlink(NODE *h) NODE *p; p=h->next; printf("n The LIST :nn HEAD"); while(p) printf("-

50、>%d",p->data); p=p->next; printf("n");main() NODE *head; head=Creatlink(8,22); outlink(head);【參考答案】p=s;【參考答案】s->data=rand()%(m-1);【參考答案】return h;return (h);/*已知學生的記錄由學號和學習成績構(gòu)成,N名學生的數(shù)據(jù)已存入a結(jié)構(gòu)體中,給定程序的功能是找出成績最低的學生記錄,通過形參返回主函數(shù)。注意:部分源程序給出如下。請勿改動main函數(shù)和其他函數(shù)中的任何內(nèi)容,僅在函數(shù)fun的橫線上填入所編寫

51、的若干表達式或語句。 本題程序: */#include <stdio.h>#include <string.h>#define N 10typedef struct ss /*定義結(jié)構(gòu)體*/ char num10; int s; STU;fun(STU a, STU *s)/*FILL*/ 【1】 h; int i; h=a0; for(i=1;i<N;i+)if(ai.s<h.s)/*FILL*/【2】=ai;/*FILL*/ *s=【3】;main() STU aN= "A01",81, "A02",89, &qu

52、ot;A03",66, "A04",87, "A05",77, "A06",90, "A07",79, "A08",61, "A09",80, "A10",71,m; int i; printf("*The original data*"); for(i=0;i<N;i+) printf("No=%s Mark=%dn", ai.num,ai.s); fun(a,&m);printf(&quo

53、t;*THE RESULT*n"); printf("The lowest :%s, %dn",m.num,m.s);【參考答案】STU【參考答案】h【參考答案】h/*人員的記錄由編號和出生年、月、日組成,N名人員的數(shù)據(jù)已在主函數(shù)中存入結(jié)構(gòu)體數(shù)組std中,且編號唯一。函數(shù)fun的功能是:找出指定編號人員的數(shù)據(jù),作為函數(shù)值返回,由主函數(shù)輸出,若指定編號不存在,返回數(shù)據(jù)中的編號為空串。 注意:部分源程序給出如下。 請勿改動main函數(shù)和其他函數(shù)中的任何內(nèi)容,僅在函數(shù)fun的橫線上填入所編寫的若干表達式或語句。 試題程序: */#include <stdio.h>#include <string.h>#define N 8typedef struct char num10;int year,month,day;STU;/*FILL*/ 1 fun(STU *std,char *num)int i;STU a="",9999,99,99;for(i=0;i<=N;i+)/*F

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論