欢迎来到天天文库
浏览记录
ID:11855634
大小:80.36 KB
页数:109页
时间:2018-07-14
《数据结构题集(c语言版)算法设计题答案》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、WinTSDInc.第一章绪论www.wintsd.com1.16voidprint_descending(intx,inty,intz)//按从大到小顺序输出三个数{scanf("%d,%d,%d",&x,&y,&z);if(xy;//<->为表示交换的双目运算符,以下同if(yz;if(xy;//冒泡排序printf("%d%d%d",x,y,z);}//print_descending1.17Statusfib(intk,intm,int&f)//求k阶斐波那契序列的第m项的值f{inttempd;if(k<2
2、
3、m
4、<0)returnERROR;if(m5、18typedefstruct{char*sport;enum{male,female}gender;charschoolname;//校名为'A','B','C','D'或'E'char*result;andactivelycarryoutinvestment.Thisyear,theintroductionofoverseasChineseof220,000yuan,WeiJiaGouJian,Chongxinhopeprimaryschool1.Localrecordscompilationwork,ensurethatthelogis109www.wint6、sd.comWinTSDInc.intscore;}resulttype;typedefstruct{intmalescore;intfemalescore;inttotalscore;}scoretype;voidsummary(resulttyperesult[])//求各校的男女总分和团体总分,假设结果已经储存在result[]数组中{scoretypescore;i=0;while(result[i].sport!=NULL){switch(result[i].schoolname){case'A':score[0].totalscore+=result[7、i].score;if(result[i].gender==0)score[0].malescore+=result[i].score;elsescore[0].femalescore+=result[i].score;break;case'B':score.totalscore+=result[i].score;if(result[i].gender==0)score.malescore+=result[i].score;elsescore.femalescore+=result[i].score;break;………………}i++;}for(i=0;i<5;i+8、+){printf("School%d:",i);printf("Totalscoreofmale:%d",score[i].malescore);printf("Totalscoreoffemale:%d",score[i].femalescore);printf("Totalscoreofall:%d",score[i].totalscore);}}//summary1.19Statusalgo119(inta[ARRSIZE])//求i!*2^i序列的值且不超过maxint{last=1;for(i=1;i<=ARRSIZE;i++){a9、[i-1]=last*2*i;if((a[i-1]/last)!=(2*i))reurnOVERFLOW;last=a[i-1];returnOK;andactivelycarryoutinvestment.Thisyear,theintroductionofoverseasChineseof220,000yuan,WeiJiaGouJian,Chongxinhopeprimaryschool1.Localrecordscompilationwork,ensurethatthelogis109www.wintsd.comWinTSDInc.}}//algo119分10、析:当某一
5、18typedefstruct{char*sport;enum{male,female}gender;charschoolname;//校名为'A','B','C','D'或'E'char*result;andactivelycarryoutinvestment.Thisyear,theintroductionofoverseasChineseof220,000yuan,WeiJiaGouJian,Chongxinhopeprimaryschool1.Localrecordscompilationwork,ensurethatthelogis109www.wint
6、sd.comWinTSDInc.intscore;}resulttype;typedefstruct{intmalescore;intfemalescore;inttotalscore;}scoretype;voidsummary(resulttyperesult[])//求各校的男女总分和团体总分,假设结果已经储存在result[]数组中{scoretypescore;i=0;while(result[i].sport!=NULL){switch(result[i].schoolname){case'A':score[0].totalscore+=result[
7、i].score;if(result[i].gender==0)score[0].malescore+=result[i].score;elsescore[0].femalescore+=result[i].score;break;case'B':score.totalscore+=result[i].score;if(result[i].gender==0)score.malescore+=result[i].score;elsescore.femalescore+=result[i].score;break;………………}i++;}for(i=0;i<5;i+
8、+){printf("School%d:",i);printf("Totalscoreofmale:%d",score[i].malescore);printf("Totalscoreoffemale:%d",score[i].femalescore);printf("Totalscoreofall:%d",score[i].totalscore);}}//summary1.19Statusalgo119(inta[ARRSIZE])//求i!*2^i序列的值且不超过maxint{last=1;for(i=1;i<=ARRSIZE;i++){a
9、[i-1]=last*2*i;if((a[i-1]/last)!=(2*i))reurnOVERFLOW;last=a[i-1];returnOK;andactivelycarryoutinvestment.Thisyear,theintroductionofoverseasChineseof220,000yuan,WeiJiaGouJian,Chongxinhopeprimaryschool1.Localrecordscompilationwork,ensurethatthelogis109www.wintsd.comWinTSDInc.}}//algo119分
10、析:当某一
此文档下载收益归作者所有