资源描述:
《C语言程序设计 教学课件 作者 罗朝盛第8章 习题参考答案.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、《C语言程序设计》习题参考答案第8章习题参考答案1.思考题(略)2.判断题:123456√×××√√3.选择题12345678ADDBDADD4.程序阅读(1)2,4,6,8,10,。(2)10987654321(3)Shen。(4)18。1-57(5)5.程序填空(1)p->next!=NULLinfop=p->next;(2)p1->next!=NULLp0->next=p1;p0->next=NULL;(3)s[k].avers[k].aver>s[maxsub].avermaxsub=k(4)max=i;min=i;stud[max].name,stud[max].scores
2、tud[min].name,stud[min].score(5)headn++p->next6.编程题(1)structcomplx{intreal;intim;};main(){structcomplxc1,c2,c3;scanf("%d+%di",&c1.real,&c1.im);scanf("%d+%di",&c2.real,&c2.im);c3.real=c1.real*c2.real-c1.im*c2.im;c3.im=c1.real*c2.im+c1.im*c2.real;printf("(%d+%di)*(%d+%di)=%d+%di",c1.real,c1.im,c2.
3、real,c2.im,c3.real,c3.im);getch();}《C语言程序设计》习题参考答案(2)#include#includemain()#defineN10structstudent{longnum;charname[10];floatscore[3];floatave;};main(){voidinput(structstudents[],intn);/*输入n个学生数据*/floataverage(structstudents[],intn);/*计算第n个学生的平均成绩*/intmax(structstudents[],intn
4、);/*计算n个学生中哪个学生的平均成绩最高*/structstudents[N];inti,m;floata=0;/*总平均成绩*/input(s,N);for(i=0;i5、.ave);printf("Thetotalaveragescoreis%f",a);m=max(s,N);printf("Themaxscorestudent:");printf("Number:%ldName:%sScore1:%fScore2:%fScore3:%fAverageScore:%f",s[m].num,s[m].name,s[m].score[0],s[m].score[1],s[m].score[2],s[m].ave);}voidinput(structstudents[],intn){inti;for(i=0;i6、《C语言程序设计》习题参考答案printf("Pleaseinputstudentnumber:");scanf("%ld",&s[i].num);printf("Pleaseinputstudentname:");scanf("%s",s[i].name);printf("Pleaseinputstudentscore1:");scanf("%f",&s[i].score[0]);printf("Pleaseinputstudentscore2:");scanf("%f",&s[i].score[1]);printf("Pleaseinputstudentscore3:");scan
7、f("%f",&s[i].score[2]);}}floataverage(structstudents[],intn){inti;floata=0;for(i=0;i<3;i++)a=a+s[n].score[i];a=a/3;return(a);}intmax(structstudents[],intn){inti,m=0;for(i=1;is[m].ave)m=i;return(m);}(3)stru