C语言程序设计课后习题答案第四版谭浩强完整版_第1页
C语言程序设计课后习题答案第四版谭浩强完整版_第2页
C语言程序设计课后习题答案第四版谭浩强完整版_第3页
C语言程序设计课后习题答案第四版谭浩强完整版_第4页
C语言程序设计课后习题答案第四版谭浩强完整版_第5页
已阅读5页,还剩594页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

题答案第四版谭浩强printf("VeryGood!\n\n");}}}}}}3-3.m=log10(p/(p-d*r))/log10(1+r);}printf("c1=%c,c2=%c\n",c1,c2);printf("c1=%d,c2=%d\n",c}printf("a=%d,b=%d,x=%f,y=%f,c1=%c,c2=%c\n",a,b,}printf("passworis%c%c%c%c%c\n",c1,c2}vz=pi*r*r*h;printf("圆周长为:l=%printf("圆面积为:s=%printf("圆球表面积为:sq=%6printf("圆球体积为:v=%6printf("圆柱体积为:vz=%6}{}{}{}{}{}}{}}{}}4-6.printf("x=%3d,y=x=%}printf("x=%d,y=2*x-1=}printf("x=%d,y=3*x-11=}}{}{}}}printf("成绩是%5.1f,相应的等级是%c\n",sco}{thousand=(int)(num-thundred=(int)(num-ten_thousand*10000-thousandten=(int)(num-ten_thousand*10000-thousaindiv=(int)(num-ten_thousand*1printf("%d%d%d%d%d\n",indiv,ten,hundred,thousand,tencase4:printf("%d,%d,%d,%d",thousprintf("%d%d%d%d\n",indiv,ten,hundredcase3:printf("%d,%d,printf("%d%d%d\n",indiv,te}}{bonus=bon10+(i-1000printf("奖金是:%10.2f}{case9:bonus=bon6+}printf("奖金是%10.2f\n",b}printf("a=%d,b=%d,c=%d,d=%d\n}{floatx1=2,y1=2,x2=-2,y2=2,x3=-2,y3=-2,x4=2,y4=-2,x,y,d1,d2,d3,d4;d1=(x-x4)*(x-x4)+(y-y4)*(y-y4);d2=(x-x1)*(x-x1)+(y-y1)*(y-y1);}math.n{while(fabs(term)>=1e-8){}printf("pi=%10.8f\n",pprintf("count=%d\n",count}{{}while(m!=0){}printf("它们的最小公约数为:%}{intletters=0,space=0,digwhile((c=getchar())!='\n'){}}{{}printf("a+aa+aaa+...=%d\n",sn);}{}printf("1!+2!+...+20!=%22.15e\n",s);}{printf("sum=%15.6f\n"}{{}}{intk1,k2,k3,k4,k5,k}}{}}}}}}{{}printf("sum=%16.10f\n}{{}}{}}{printf("enterapositivenumber:");}}}}}}}}{printf("A--%c\nB--%c\nC--%c}}}}}}}printf("Theorginalnumbers:\n}printf("\nThesortednum}{printf("enterdata:\n");}printf("arraya:\n"}}}}printf("Nowarraya:\n");}}}}a[i][j]=a[i-1][j-1]+a[i}}while(p==1)}}}}}}}{printf("pleaseinputmatrix:\n");}}}}printf("enterdata:\n");while(i<N)}while(flag)}}printf("cannotfind%d.\n}}}}printf("\nuppercase:%d\n",uprintf("lowercase:}}}printf("inputciphercode:"}printf("\noriginaltext:");}printf("inputciphercode:\n");printf("\nciphercode:%s\n",ch);}printf("originaltext:");}}printf("inputstring1:printf("\ninputstring2:printf("\nresult:%d.\n",re}}}}{}}}}{}voidsmaller_than_zeroprintf("equation:%5.2f*x*x+%5.2f*x+%5.2f=0{printf("x1=%f\t\tx2=%f\n",x1,x2);}printf("x1=%f\t\tx2=%f}printf("x1=%f+%fi\tx2=%f-%fi\n",p,q,p,q);}}voidgreater_than_zero(floata,floatb)x2=(-b-sqrt(disc))/(}voidequal_to_zero(floata,floatb){}voidsmaller_than_zero(floata,floatb){}}}}}}voidconvert(intarray[][3])array[i][j]=array[j][i];}}printf("inversestring:}}}printf("inputstring1:");}voidconcatenate(charstring1[],charstring2[],charstring[])for(j=0;string2[j]!='\0';j++)}printf("inputstring:");printf("Thevowelletter}s[i]=='I'||s[i]=='o'||s}}printf("inputfourdigits:");}}printf("output:\n%s\n",str);}printf("\nletter:%d\ndigit:%d\nspace:%d\nothers:%d\n",letter,digit,}}}}}}}}}printf("stringsorted:\n");}}}printf("x=%10.7f\n",solut}}while(fabs(x-x0)>=1e-3);}}printf("highest:%7.2fNO.%2dcourse%2dprintf("variance%8.2f\n}}}voidaver_stu(void)}}voidaver_cour(void)}}high=score[0][0];}}}return(sumx/N-(sumxn/N)*(sumxn/N));}floata_stu[N],a_cour}printf("%8.2f",a_courprintf("highest:%7.2fNO.%2dcourse%2dprintf("variance%8.2f\n}}}voidaver_stu(void)}}voidaver_cour(void)}}high=score[0][0];}}}return(sumx/N-(sumxn/N)*(sumxn/N));}}}voidinput(intnum[]}}voidsort(intnum[],charname[N][8])}printf("\n%5d%10s",num[i}voidsearch(intn,intnum[],charname[N][8])}}printf("%dnotbeenfo}printf("inputaHEXwhile((c=getchar())!='\0'&&i<MAX&&flag1)}printf("decimalnumber%d\nprintf("\ninputaHEX}}}}}}}}}printf("inputdate(year,month,day):"printf("%d/%d/%d",year,month,da}day+=day_tab[i];leap=year%4==0&&year%1}printf("Now,theorderis:%d,%d,%d\n"}p=*p1;*p1=*p2;*p2=p;}charstr1[20],str2[2printf("%s\n%s\n%s\n",str1,}strcpy(p,p1);strcpy(p1,p2);strcpy(p2,}voidmax_min_value(int*);max_min_value(number);}}voidmax_min_value(int*numbemax=min=number;temp=number[0];number[0]=*min;temp=number[9];number[9]=*max;}voidoutput(int*nu}printf("howmanynumbers");printf("input%dnumbers:\n",n);printf("howmanyplaceyouw}voidmove(intarray[20],}printf("\ninputnumberofperson:n=");}}while(*p==0)p++;}}}}printf("inputstring:");}}voidcopystr(char*p1,char*p2,int}}}}}digit:%dother:%dprintf("inputmatrix:\n"scanf("%d%d%d",&a[i][0],&a[iprintf("Now,matrix:\nprintf("%d%d%d\n",a[i][0],a[i][1}*(pointer+3*i+j)=*(pointer+3*j+i}}}}}}}}}}temp=*pmin;}temp=*pmin;}}}}}}}}}}}}floatintegral(float(*p)(float),float}}}}}voidfali2(charcourse[5][10],intnum[],float*pscore,flovoidgood(charcourse[5][10],intnum[4],float*pscore,flofloatscore[4][5],avprintf("inputNO.andsco}paver=&aver[0];printf("\n\n");avsco(pscore,paver);//求出每avcour1(pcourse,pscore);//求出第printf("\n\n");printf("\n\n");good(pcourse,pnum,pscore,paver);}voidavsco(float*pscore,float*paver)//求每average=sum/5;}}sum=sum+(*(pscore+5*iaverage1=sum/4;printf("course1:%saveragescore:%7.2f\n",*pcourse}voidfali2(charcourse[5][10],intnum[],float*pscore,flprintf("%11.2f",*(psco}}}voidgood(charcourse[5][10],intnum[4],float*pscore,floataver[4])printf("======Studentswhprintf("%11.2f",*(psco}}}{while(*(pstr+i)!='\0')digit=digit+(*(pstr+i-1-k)-48)}}}}}}printf("%d",*(pa+j)}}while(*(p1+i)==*(p2+}"May","June","july","August","September","October","November","Decprintf("inputmonth:printf("Itis%s.\n",*(month_name+n)}char*new(intn)}}}#defineLINEMAX20/*定printf("stringssor}}}}}printf("input%dintegernu}}}}}printf("inputyear,moscanf("%d,%d,%d",&date.y}printf("%d/%disthe%dthday}printf("inputyear,moscanf("%d,%d,%d",&date.yif((date.year%4==0&&datprintf("%d/%disthe%dthdayin%d.\n",date.month,date.day,days,date.year);}#include<stdio.h>printf("inputyear,moscanf("%d,%d,%d",&date.y}case4:sum=date1.day+}}printf("inputyear,moscanf("%d,%d,%d",&date.yday_sum=days(date.year,dat}}}}}printf("%9d",stu[i].sc}}}}}}printf("%9d",stu[i].score[j]);}}}}}printf("%9.2f",stu[i].scprintf("%8.2f\n",stu[}printf("average=%5.2f\nprintf("hisscoresare:%6.2f,%6.2f,%6.2f,averagestu[maxi].score[0],stu[maxi].score[1],stu[ma}}}printf("%4d",link[h}printf("%3d",link[i}}while(num!=p1->num&&p1->next!=NULL)elsep2->next=p1->next;}elseprintf("%ldnotbeenfound}//使p1指向第一个结点//使p0指向的结点作为头结点{p2=p1;//使p2指向刚才p1指向的结点}p0->next=NULL;/}}n=n+1;//结点数加1}}p1=(structstudent*)m}}}while(num!=p1->num&&p1->next!=NULL)printf("delete:%ld\n",num}}}}}}printf("\nNow,These%drecords}printf("inputrecords:\printf("inputthedel}p1=(structstudent*)m}}}while(num!=p1->num&&p1->next!=NU}}}}}}printf("\nNow,These%drecords}}}p1=(structstudent*)m}}while(num!=p1->num&&p1->next!=NU}}}}}printf("\nNow,These%drecordsare:\n",n);}}p1=p2=(structstudent*)mp1=(structstudent*)m}}}}}}b[LB]={{103,"Zhang"},{104,"Ma"},{105,"Chen"},{107,"Guo"},{10printf("%4d%8s\n",p1->num}printf("%4d%8s\n",p2->num}}}}}}}}}}}printf("notfoundprintf("\nNO.nprintf("%6s%6d\n",p->s}}{}}}{}{}}printf("\nfileB:\n}}}}}}printf("filewriteerror\n"printf("\n%s,%s,%d,%d,%d,%6.2f\n",stu[i].num,stu[i].name,stu[i].s}&stud[i].score[1],&stud[i].score[2sum[i]=stud[i].score[0]+stud[i}printf("-----------------------------------------printf("%-10s%3d%7d%7d%7d%8.2f\n",stud[i].name,sstud[i].score[0],stud[i].score[1],st}}{}}}#include<stdlib.h>}printf("%8d",st[i].scprintf("%10.2f",st[}}printf("\n%8s%8s",st[i].num,st[printf("%10.2f",st[}}{{printf("----------------------------------------------printf("NAMEN0.SCOprintf("----------------------------------------------{fread(&stud[i],sizeof(sprintf("%-10s%3d%8d%8d%8d%9.2f\n",stud[i].name,sstud[i].score[0],stud[i].score[1],st}}}}}}fwrite(&stud[i],sizeof(st}}printf("score1,score2scanf("%d,%d,%d",&s.score[}printf("%8d",st[i].scprintf("%10.2f",st[}printf("\n%8s%8s",st[i].num,st[printf("%8d",st[i].scprintf("%10.2f",st[}fwrite(&s,sizeof(stprintf("\n%8s%7s%7d%7d%7d%10.2f",s.num,,s.sprintf("\n%8s%8s",st[i].num,st[printf("%8d",st[i].scprintf("%10.2f",st[}}printf("score1,score2scanf("%d,%d,%d",&s.score[}printf("%8d",st[i].scprintf("%10.2f",st[}printf("\n%8s%8s",st[i].num,st[printf("%8d",st[i].scprintf("%10.2f",st[}fwrite(&s,sizeof(stprintf("\n%

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论