![c语言答案参考(Clanguageanswerreference)_第1页](http://file4.renrendoc.com/view/708df00002b99342507a8ef2d9bc0173/708df00002b99342507a8ef2d9bc01731.gif)
![c语言答案参考(Clanguageanswerreference)_第2页](http://file4.renrendoc.com/view/708df00002b99342507a8ef2d9bc0173/708df00002b99342507a8ef2d9bc01732.gif)
![c语言答案参考(Clanguageanswerreference)_第3页](http://file4.renrendoc.com/view/708df00002b99342507a8ef2d9bc0173/708df00002b99342507a8ef2d9bc01733.gif)
![c语言答案参考(Clanguageanswerreference)_第4页](http://file4.renrendoc.com/view/708df00002b99342507a8ef2d9bc0173/708df00002b99342507a8ef2d9bc01734.gif)
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
c语言答案参考(Clanguageanswerreference)Firstquestions,mpersonalresultsstoredinthescorearray,pleasewritethefunctionfun,itsfunctionis:lowerthantheaveragepersonasafunctionvaluereturned,willbelessthantheaveragescoreplacedinthebelowspecifiedfunction.Answer:Intfun(int,score[],int,m,int,below口)iInt,I,k=0,aver=0;For(i=0;I<m;i++)Aver+=score[i];Aver/=m;For(i=0;I<m;i++)If(score[i]<aver)(Below[k]=score[i];K++;Returnk;2:secondquestionspleasewritethefunctionfun,itsfunctionis:1to100canbeobtained7Northordivisibleby11,butallthecertificateisnotdivisibleby11and7atthenorth,andputtheminthearraypointedtobya,returnsthenumberofthesenumbersbyn.Answer:Voidfun(int,*a,int,*n){Int,I,j=0;For(i=2;I<1000;i++)(if(i%7==0IIi%ll==0)&&i%77!=0)A[j++]=i;*n=j;)Pleasewritethefunctionvoid3:thirdfun(intx,intppロ,int*n),itsfunctionistocalculatetheintegers:Xandisnoteven,andthearrayonthePPreferredtotheorderfromsmalltolarge,thedivisorofthenumberreturnedthroughtheparametern.Answer:Void,fun(int,x,int,pp[],int,*n)[Int,i=l,j=0,k=0,*t=pp;For(i=0;I<=x;i++)If(i%2,=0)iT[j]=I;J++;)For(i=0;I<J;i++)If(x%t[i]==0)Pp[k]=t[i];K++;*n=k;fourthquestions,pleasewriteafunctionvoidfun(char*tt,intppロ),statisticsintheTTcharacters,z,ato"Z"26lettersappearinthenumberoftimes,andinturnplacedinthePPreferstothearray.Answer:Voidfun(char,*tt,int,pp[])For(i=0;I<26;i++)Pp[i]=0;While(*tt)Switch(*tt)Case'a':pp[〇]++;break;Case'B':pp[l]++;break;Case'C':pp[2]++;break;Case'd':pp[3]++;break;Case'e':pp[4]++;break;Case'f':pp[5]++;break;Case'g':pp[6]++;break;Case'H':pp[7]++;break;Case'I':pp[8]++;break;Case'J':pp[9]++;break;Case'k':pp[10]++;break;Case'1':pp[ll]++;break;Case'm':pp[⑵++;break;Case'n':pp[12]++;break;Case’〇':pp[14]++;break;Case'p':pp[15]++;break;Case'Q':pp[16]++;break;Case'R':pp[17]++;break;Case's':pp[18]++;break;Case't':pp[19]++;break;Case'U':pp[20]++;break;Case'V':pp[21]++;break;Case'W':pp[22]++;break;Case'x':pp[23]++;break;Case'y':pp[24]++;break;Case'Z':pp[25]++;break;Tt++;fifthquestions,pleasewriteafunctionvoidfun(int,m,int,K,int,xx[]),thefunctionofthisfunctionis:willbegreaterthantheintegermandclosetotheMK,theprimevaluesstoredintheXXreferstothearray.Answer:Voidfun(int,m,int,K,int,xx口){Int,g=0,I,J,flag=l;For(i=m+l;I<m*m;i++)iFor(j=0;J<I;j++)!If(i%j,=0)Flag=l;ElseFlag=0;Break;If(flag==landj>=i)!If(k>=0)(Xx[g++]=i;K—;}ElseBreak;sixthquestions,pleasewriteafunctionvoidfun(char,a[],char[],int,n),itsfunctionis:deletecharactersineachstringspecifiedsubscript.Whereapointstotheoriginalstring,ThedeletedstringisstoredinanarrayreferredtobyB,andthespecifiedsubscriptisstoredinthen.Answer:Voidfun(char,a[],char,b[],int,n)(Int,I,j=0;For(i=0;I<LEN;i++)If(I,=n)!B[j]=a[i];J++;B[j]='、0’;seventhquestions,pleasewriteafunctionintfun(int,*s,int,t,int,*k),usedtofindthelargestelementinthearrayexcepttheindexinthearray,andstoredintheKreferstothestorageunit.Answer:Voidfun(int,*s,int,t,int,*k){Int,I,max;Max=s[0];For(i=0;I<T;i++)If(s[i]>max)!Max=s[i];*k=I;eighth,writefunctionfun,functionis:accordingtothefollowingoffensivecalculations,theresultsofthecalculationasafunctionvaluetoreturn;Nthroughtheparametersoftheincoming.S=l+1/(1+2)+1/(1+2+3)+ +1/(1+2+3+4+ +n)Answer:Floatfun(intn)!Inti;Float,s=l.0,t=l.0;For(i=2;Iく=n;i++)IT=t+i;S=s+l/t;}Returns;)ninthquestionswriteafunctionfun,itsfunctionis:accordingtothefollowingformulaforthevalueofP,theresultbythefunctionvaluetobringback,MandNaretwopositiveintegersandrequirem>n.P=m!/n!(m-n)!Answer:Floatfun(int,m,int,n)(Float,P,t=l,0;IntI;For(i=l;I<=m;i++)T=t*l;P-t;For(t=l.0,i=l;1<=n;i++)T=t*I;P=p/t;For(t=l.0,i=l;!く=m-n;i++)T=t*I;P=p/t;Returnp;tenthquestionswritefunctionfun,itsfunctionis:usethefollowingsimpleiterativemethodtofindtheequationcos(x)-x=0arealroot.Theiterativestepsareasfollows:(1)taketheinitialvalueofXIto0;(2)x0=xltoassignthevalueofXItoeachxO;xl=cos(xO),andfindanewxl;iftheabsolutevalueofx0-xlislessthan0.000001,thestep(5)isexecuted,orthestep(2)isexecuted;theXIisarealrootoftheequationcos(x)-x=0,whichisreturnedasafunctionvalue.Theprogramwilloutputroot=0.739085.Answer:Float,fun()Float,xl=0.0,xO;DoXO=xl;Xl=cos(xO);)While(Fabs(xO-xl)>le-6);Returnxl;}eleventhquestions,thefollowingproceduresdefinethen*ntwo-dimensionalarray,andautomaticallyassignedinthemainfunction.Pleasewritethefunctionfun(inta[][n]).Thefunctionofthisfunctionistomakethevaluesinthelowerlefttriangleofthearrayallsetto0.Answer:Intfun(inta[][N])(Int,I,j;For(i=0;I<N;i++)For(j=0;J<=1;j++)twelfthquestions,thefollowingproceduresdefinethen*ntwo-dimensionalarray,andinthemainfunctionassignment.Pleasewritethefunctionfun,functionfunction,sothattheaveragevalueofthearrayperipheralelements,andasafunctionvaluereturnedtothemainfunctionofthes.Answer:Doublefun(intw[][N]){Int,I,J,k=0;Doubles=0.0;For(j=0;J<N;j++)(S+=w[0][j];K++;For(j=0;J<N;j++)S+=w[N-l][j];K++;)For(i=l;I<=N-2;i++)(S+=w[i][0];K++;)For(i=l;I<=N-2;i++)IS+=w[i][N-1];K++;Returns/=k;thirteenthquestions,pleasewriteafunctionvoidfun(inttt[m][n],intpp[n]),TTpointtoamrow,ncolumnoftwo-dimensionalfunctionset,findthetwo-dimensionalfunctiongroup,eachcolumnofthesmallestelement,andthenplacedinthePPspecifiedone-dimensionalarray.Thenumberinthetwo-dimensionalarrayisgiveninthemainfunction.Answer:Voidfun(int,tt[M][N],int,pp[N])IInt,I,J,min;For(j=0;J<N;j++)!Min=tt[〇][j];For(i=0;I<M;i++){If(tt[i][j]<min)Min=tt[i][j];Pp[j]=min;fourteenthquestion,pleasedon'twritefunctionfun,Functiontofindthesumofthesurroundingelementsofatwo-dimensionalarray,andreturnitasafunctionvalue.Valuesinatwo-dimensionalarrayaregiveninthemainfunction.Answer:Intfun(inta[M][N])!Int,I,J,s=0;For(j=0;J<N;j++){S+=a[0][j];S+=a[M-l][j];For(i=l;I<=M—2;i++)(S+=a[i][0];S+=a[i][N-1];)Returns;)fifteenthquestionspleasewriteafunctionunsignedfun(unsignedw),wmakesagreaterthan10unsignedinteger,ifwn(n=2)bitintegerfunctionforWn-thenumber1asafunctionreturnvalue.Answer:Unsignedfun(unsignedw){Unsigned,t,s=0,sl=l,p=0;T=w;If(t/10)P=t%10;S=s+p*sl;Sl=sl*10;T=t/10;)Returns;}sixteenthquestions,pleasewriteafunctionfloatfun(doubleh),thefunctionofthefunctionsothatthevariableHinthevalueof2smalltreesretained,andthirdbitsforfourtofive(specifythevalueofHbitpositive).Answer:Floatfun(floath)Longt;Floats;H=h*100〇;T=(h+5)/10;S=(float)t/100.0;Returns;)seventeenthquestions,pleasewriteafunctionfun(char*s),thefunctionofthefunctiontomakethecontentsofthestringtobeset.Answer:Voidfun(char*s)(Charch;Int,I,m,n;1=0;M=n=strlen(s)-1;While(I<(n+1)/2){Ch=s[i];S[i]=s[m];S[m]=ch;1++;M一;))eighteenthquestionswrittenprocedures,therealizationofthematrix(3rows,3columns)transpose(1inecolumnswap).Answer:Voidfun(intarray[3][3])Int,I,J,temp;For(i=0;I<3;i++)For(j=0;J<I,j++){Temp=array[i][j];Array[i][j]=array[j][i];Array[j][i]=temp;})nineteenthquestionswritefunctionfun,thefunctionofthefunctionis:fromthecharacterstodeletethespecifiedcharacters,thesameletteroflarge,lowercase,accordingtodifferentcharactersprocessing.Answer:Voidfun(char,s[],int,c)!Inti=0;Char*p;While(*p){If(*P,=c)[S[i]=*p;1++;)P++;)S[i]=,、〇,;)twentiethquestionswritefunctionintfun(intLim,intaa[max]),thefunctionofthefunctionistofindlessthanorequaltoalltheprimeLim,andplacedintheAAarray,thefunctionreturnsthenumberoftheprimenumberrequested.Answer:Intfun(int,Lim,int,aa[MAX])Int,k=0,I,j;For(i=lim;i>l;i一){For(j=2;J<I;j++)If(i%j==0)Break;ElseContinue;If(j>=i)(Aa[k]=i;K++;Returnk++;twenty-firstquestions,pleasewritefunctionfun,thelengthof7charactersstring,inadditiontothebeginningandendcharacters,theremaining5charactersindescendingorderASCIIcode.Answer:Voidfun(char,*s,int,Num)IChart;Int,I,j;For(i=l;I<num-2;i++)For(j=i+l;J<num-1;j++)If(s[i]<s[j]){T=s[i];S[i]=s[j];S[j]=t;twenty-secondquestionnstudents'scoreshavebeenplacedinthemainfunctioninalistofleadingnodesintheliststructure,Hpointingtotheheadernodeofthelist.Pleasewritethefunctionfun,whosefunctionistofindthehighestscoreofthestudentandreturnitbythefunctionvalue.Answer:Doublefun(STREC*h)IDoublemax;STREC*q=h;Max=h->s;DoIf(q->s>max)Max=q->s;Q=q->next;)While(Q,=0);Returnmax;)twenty-thirdquestions,pleasewritefunctionfun,thefunctionofthefunctionis:determinewhetherthestringispalindrome,ifthefunctionreturns1,themainfunctionoftheoutputyes,otherwisereturn0,themainfunctionoftheoutputNo.Apalindromeisastringthatreadsthesamewayandreadsthesame.Answer:Intfun(char*str)Int,I,n=0;fg=l;Char*p=str;While(*p)N++;P++;)For(i=0;I<n/2;i++)If(str[i]==str[n-l-i]);ElseiFg=0;Break;)Returnfg;)twenty-fourth,writeafunctionfun,whichconvertsastringtoaninteger(nottocalltheClanguagetoconvertstringsintointegers).Answer:Longfun(char*p)(Long,s=0,t;Int,i=0,J,n=strlen(P),K,si;If(p[0]=='1++;For(j=I;J<=n-l;j++){T=p[j]-'。’;Sl=10;For(k=j;K<n-1;k++)T*=sl;S+=t;If(p[0]=>-)Return-s;ElseReturns;)twenty-fifthquestion,pleasewriteafunctionfun,anditsfunctionis:comparethelengthoftwostrings(notcalltheClanguagetoprovidethestringlengthfunction),functionreturnsalongerstring.Ifthetwostringsarethesamelength,thefirststringisreturned.Answer:Char*fun(char,*s,char,*t)!Char,*p,*tl=t,*sl=s;Intn=0;m=0;While(*sl)S1++;While(*tl)[M++;T1++;)If(n>=m)P=s;ElseP=t;Returnp;}twenty-sixthquestions,pleasewriteafunctionfun,itsfunctionis:accordingtothefollowingformulaforthevalueofX(requiredtomeettheaccuracyof0.0005,thatislessthan0.0005whenastopiteration):X/2=l+l/3+lx2/3x5+1x2x3/3x5*7+1*2x3*4/3*5*7*9+...+1x2x3x...*n/3x5x7x(2n+l)Aftertheprogramisrun,iftheinputprecisionis0.0005,theprogramoutputis3.14....Answer:Doublefun(doubleEPS)(Doubles;Float,N,t,pi;T=l;pi=0;n=1.0;s=l.0;While((Fabs(s))>=eps){Pi+=s;T=n/(2*n+l);S*=t;Pi=pi*2;Returnpi;)twenty-seventhquestions,pleasewriteafunctionfun,itsfunctionis:toeliminate1tom(includingm),cannorth7or11divisibleal1integersinthearraya,throughntoreturnthenumberofthesenumbers.Answer:Voidfun(int,m,int,*a,int,*n)IInt,I,j=0;*n=0;For(i=l;I<=m;i++)If(i%7==0i%ll==0II)!J++;*n=j;twenty-eighth,writeafunctionfun,whichistofindthemaximumvalueoftheelementinanintegerarrayandtheindexitisin.Themaximumvalueanditssubscriptarereturnedbytheparameter.Thevaluesinthearrayelementaregiveninthemainfunction.Inthemainfunction,Xisthearrayname,nisthenumberofdatainX,Maxholdsthemaximumvalue,andindexstorestheindexoftheelementwherethemaximumvalueisstored.Answer:Void,fun(int,a[],int,N,int,*max,int,*d)(IntI;*max=a[0];*d=0;For(i=0;I<n;i++)If(a[i]>*max)*max=a[i];*d=I;))twenty-ninthquestion,pleasewriteafunctionfun,itsfunctionis:theSSstringreferstoalltheindexintheoddnumberoflettersonthelocationintouppercase(ifthelocationisnotletters,butnotconverted).Answer:Voidfun(char*ss)(Int,I,n;N=strlen(SS);For(i=l;I<n;i+=2)If(ss[i]>='a&&ss[i]く='Z')Ss[i]=ss[i]-32;thirtiethquestions,pleasewriteafunctionfun,itsfunctionis:inadditiontoa2*mintegertwo-dimensionalarrayofthemaximumelementvalue,andthevaluereturnedtocallthefunction.Answer:Intfun(inta[][M])(Int,I,J,max;Max=a[0][0];For(i=0;I<2;i++)For(j=0;J<M;j++)If(a[i][j]>max)Max=a[i][j];Returnmax;)thirty-firstquestionspleasewritethefunctionfun,itsfunctionis:sreferstoastringofevenatthesametime,inadditiontothesubscriptASCIIvalueiseventhecharacters,alltherestofthedeletionofanarrayisformed;theremainingcharacterstringinanewseriesontheTreferstothe.Answer:Voidfun(char,*s,char,t[])[Int,I,j=0,n;N=strlen(s);For(i=0;I;n;i++)If(i%2==0&&s[i]%2==0)[T[j]=s[i];J++;)T[j]='、0’;thirty-secondquestionspleasewritethefunctionfun,itsfunctionis:sreferstothestringexceptfortheoddsubscriptvalueisodd,andASCIIcharacters,allremainingcharactersaredeleted,anarrayformedbytheremainingstringinanewseriesontheTreferstothe.Answer:Voidfun(char,*s,char,t[])!Int,I,j=0,n;N=strlen(s);For(i=0;I;n;i++)If(i%2,=0&&s[i]%2,=0)(T[j]=s[i];J++;T[j]='、0’;The33:thirty-thirdquestionassumesthattheinputstringcontainsonlylettersand*numbers.Pleasewritethefunctionfun,itsfunctionis:thestringinthetailofthe*numberofnotmorethanN;ifmorethanN,deletemorethan*;iflessthanorequaltoN,thendonotdowhatisinfrontofthemiddleofthestring,and*donotdelete.Answer:Voidfun(char,*a,int,n)(Inti=0;k=0;Char,*p,*t;P=t=a;While(*t)T++;T一;While(*t==**)K++;T-;T++;If(k>n)[While(*p&&p<t+n)(A[i]=*p;1++;P++;)A[i]='、0’;thirty-fourthstudentrecordconsistsofstudentlearningandachievement,Ndatahasbeenplacedinthemainfunctionofthestructurearrays,pleasewritethefunctionfun,itsfunction:tomakethehighestscoreofthestudents,dataonthearraypointedtobyH,note:studentsthehighestscoremaynotstopaanumberofstudents,thefunctionreturnsthehighestscores.Answer:Intfun(STREC,*a,STREC,*b)!Int,I,j=0,n=0,max;Max=a[0].s;For(i=0;I<N;i++)If(a[i].s>max)Max=a[i].s;For(i=0;I<N;i++)If(a[i].s==max)!*(b+j)=a[i];J++Returnn;)thirty-fifthquestion,writeafunctiontodeleteallspacesinastring.Answer:Voidfun(char*str){Inti=0;Char*p=str;While(*p)(If(*p=='',)Str[i]=*p;P++;)Str[i]='、O’;)The36:thirty-sixthquestionassumesthattheinputstringcontainsonlylettersand*numbers.Pleasewritethefunctionfun,whosefunctionistomovealltheleading*numbersinthestringtothetailofthestring.A
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年广东货运从业资格证模拟试题答案解析
- 2024-2025学年新教材高中地理第二章地球上的大气2.2.1大气受热过程练习含解析新人教版必修第一册
- 2024-2025学年高中语文诗歌部分第四单元河床习题含解析新人教版选修中国现代诗歌散文欣赏
- 鲁教版地理七年级下册第十一章《中国在世界中》听课评课记录1
- 模具车间主管年终总结
- 装修监理个人年终工作总结
- 客服前台工作计划范文
- 工业生产厂房租赁合同范本
- 编剧合作协议书范本
- 电玩城员工协议书范本
- 发生输液反应时的应急预案及处理方法课件
- 中国旅游地理(高职)全套教学课件
- 数字货币的匿名性与反洗钱
- 门脉高压性消化道出血的介入治疗课件
- 民航保密培训课件
- 儿童尿道黏膜脱垂介绍演示培训课件
- 诗词写作入门
- 学校教育中的STEM教育模式培训课件
- 电器整机新产品设计DFM检查表范例
- 桩基础工程文件归档内容及顺序表
- 不同产地半夏总生物碱含量测定
评论
0/150
提交评论