c语言第二版李丽娟第六章答案(可编辑)doc下载

关于c语言第二版李丽娟第六章答案.doc文档,爱问共享资料拥有内容丰富的相关文档,站内每天千位行业名人共享最新资料。

*lx*#include<stdioh>intcube(intn){inti,tfor(i=,t=i<=i)t=t*nreturnt}main(){inta,bprintf("输入一个整数:")scanf("d",a)b=cube(a)printf("d的立方是d",a,b)}*lx*#include<stdioh>#include<mathh>intinv(inta)prime(inta){intb,kif(a==)returnelseif(a==)returnelse{b=k=while(k<=sqrt(a)b){if(ak==)b=k=k}return(b)}}intinv(inta){inti,ji=aj=areturn(j*i)}main(){intnfor(n=n<=n)if(prime(n)prime(inv(n)))printf("dn",n)}*lx*#include<stdioh>main(){intfac(int)intn,k,cprintf("pleaseinput(n,k):")scanf("d,d",n,k)c=fac(n)(fac(k)*fac(nk))printf("c(d,d)=d",n,k,c)}intfac(intm){inti,s=for(i=i<=mi)s*=ireturn(s)}*lx*#include<stdioh>intfunc(){inti=,s=,n=while(s<){i*=s=in}returnn}main(){printf("最大的n=d:n",func())}*lx*#include<stdioh>intprime(intn){inti,flag=for(i=i<=ni)if(ni==){flag=returnflag}returnflag}voidfactor(intn){intii=while(i<=n){if((ni==)prime(i)){printf("d",i)n=nicontinue}i}}main(){intnumprintf("Enternum:")scanf("d",num)printf("primefactoris:n")factor(num)}*lx*#include<stdioh>floatf(intx,intn){intifloatj=for(i=i<=ni)j=j*xreturnj}floatf(intn){if(n==)returnelsereturn(f(n)*n)}main(){floatexp=intx,nprintf("Inputanumber:")scanf("d",x)printf("d",x)exp=expxfor(n=n<=n)exp=expf(x,n)f(n)printf("nTheexp(d)=fn",x,exp)}*lx*#include<stdioh>voiddelchar(charstr,charc){inti,jfor(i=,j=stri!=''i)if(stri!=c)strj=stristrj=''}main(){charstrinti,jgets(str)delchar(str,'k')puts(str)}*lx*#include<stdioh>intcompare(intx,inty){if(x==y)returnelsereturn}main(){inta,b,i,eq=,neq=printf("inputarraya:n")for(i=i<i)scanf("d",ai)printf("inputarrayb:n")for(i=i<i)scanf("d",bi)for(i=i<i)if(compare(ai,bi)==)eq=eqelseneq=neqprintf("ai=bi:dnai!=bi:dn",eq,neq)}*lx*#include<stdioh>#include<stringh>inthuiwen(charstr){inti,j,len,flag=len=strlen(str)for(i=,j=leni<=ji,j)if(stri!=strj){if(stri>strj>)*两侧都是汉字字符*{if(stri==strjstri==strj){ij}elseflag=}elseflag=}returnflag}main(){charstrprintf("Enterstring:")gets(str)if(huiwen(str))printf("sisapalindroman")elseprintf("sisnotpalindroman")}*lx*#include<stdioh>voidchange(inta,intb,intn){inti,tfor(i=i<ni){t=aiai=bibi=t}}main(){inti,a={,,,,,,,,,}intb={,,,,,,,,,}printf("ChangeBefore:")printf("nArraya:")for(i=i<i)printf("d",ai)printf("n")printf("nArrayb:")for(i=i<i)printf("d",bi)printf("n")change(a,b,)printf("ChangeAfter:")printf("nArraya:")for(i=i<i)printf("d",ai)printf("n")printf("nArrayb:")for(i=i<i)printf("d",bi)printf("n")}*lx*#include<stdioh>#definenintb={,,,,,,,,,,,,,,,}intann#definensizeofbsizeofbvoidmain(){intk,i,j,ma=bk=for(i=i<ni){for(j=kj>=ajj>bij)for(m=m<jm)ajm=ajmajj=biif(j==k)k}printf("k=dn",k)for(j=j<kj)printf("d",akj)printf("n")}*lx*#include<stdioh>#defineN#defineMintandian(intaM,intn,intm){inti,j,k,max,maxcolintflag,flag=*flag标记每一行的最大值是否鞍点flag标记矩阵是否有鞍点*for(i=i<ni){max=aifor(j=j<mj)if(aij>max){max=aijmaxcol=j}for(k=,flag=k<nflagk)if(akmaxcol<max)flag=if(flag==){printf("ndddn",i,maxcol,max)flag=}}if(flag==)return}main(){inti,j,n,m,aNMprintf("Enterrowcol:")scanf("dd",n,m)printf("Enterarrayelement:")for(i=i<ni)for(j=j<mj)scanf("d",aij)printf("n")for(i=i<ni){for(j=j<mj)printf("d",aij)printf("n")}if(andian(a,n,m)==)printf("nnoandiann")}