关闭

关闭

关闭

封号提示

内容

首页 计算机二级(2013)题库2

计算机二级(2013)题库2.doc

计算机二级(2013)题库2

马君琦 2017-10-19 评分 0 浏览量 0 0 0 0 暂无简介 简介 举报

简介:本文档为《计算机二级(2013)题库2doc》,可适用于考试题库领域,主题内容包含计算机二级()题库#include<stdioh>#include<stringh>#defineM#defineNintfun(char(*ss)符等。

计算机二级()题库#include<stdioh>#include<stringh>#defineM#defineNintfun(char(*ss)N,int*n){inti,k=,len=N**********found**********for(i=i<i){len=strlen(ssi)if(i==)*n=len**********found**********if(len*n){*n=lenk=i}}**********found**********return()}main(){charssMN={"shanghai","guangzhou","beijing","tianjing","chongqing"}intn,k,iprintf("nTheoriginalstringsare:n")for(i=i<Mi)puts(ssi)k=fun(ss,n)printf("nThelengthofshorteststringis:dn",n)printf("nTheshorteststringis:sn",ssk)}得分详细情况如下:第空参考答案:M第空参考答案:<第空参考答案:k#include<stdioh>#include<stringh>char*fun(chartt){intifor(i=ttii)**********found***********if(('a'<=tti)||(tti<='z'))**********found***********tti=return(tt)}main(){charttprintf("nPleaseenterastring:")gets(tt)printf("nTheresultstringis:ns",fun(tt))}第处参考答案:if(('a'<=tti)(tti<='z'))第处参考答案:tti=#include<stdioh>voidfun(char*s){inti,j=,k=chart,tfor(i=si!=''i)if(si>=''si<=''){**********found**********tj=si}elsetk=sitj=tk=**********found**********for(i=i<ki)**********found**********for(i=i<i)ski=ti}main,,,,},{,,,,},{,,,,}},i,jprintf("Thearraybeforemoving:nn")for(i=i<Mi){for(j=j<Nj)printf("d",xij)printf("n")}fun(x,)printf("Thearrayaftermoving:nn")for(i=i<Mi){for(j=j<Nj)printf("d",xij)printf("n")}}得分详细情况如下:第空参考答案:k考生答案:for(p=p<=p)回答错误得分第空参考答案:N考生答案:for(j=j<j)aij=aij回答错误得分第空参考答案:temp考生答案:aiN=回答错误得分#include<conioh>#include<stdioh>#defineMintaMM={}**************found**************voidfun(int**a,intm){intj,kfor(j=j<mj)for(k=k<mk)**************found**************ajk=k*j}main(){inti,j,nprintf("Entern:")scanf("d",n)fun(a,n)for(i=i<ni){for(j=j<nj)printf("d",aij)printf("n")}}得分详细情况如下:第处参考答案:voidfun(intaM,intm)考生答案:voidfun(int**a,intm)修改错误得分第处参考答案:ajk=(k)*(j)考生答案:ajk=k*j修改错误得分#include<stdioh>#defineM#defineNvoidfun(int(*a)N){inti=,j,find=,rmax,c,kwhile((i<M)(!find)){rmax=aic=for(j=j<Nj)if(rmax<aij){**********found**********rmax=aijc=}find=k=while(k<Mfind){**********found**********if(k!=iakc<=rmax)find=k}if(find)printf("find:add=dn",i,c,aic)**********found**********}if(!find)printf("notfound!n")}main(){intxMN,i,jprintf("Enternumberforarray:n")for(i=i<Mi)for(j=j<Nj)scanf("d",xij)printf("Thearray:n")for(i=i<Mi){for(j=j<Nj)printf("d",xij)printf("nn")}fun(x)}得分详细情况如下:第空参考答案:j考生答案:rmax=aijc=}回答错误得分第空参考答案:考生答案:if(k!=iakc<=rmax)find=回答错误得分第空参考答案:i考生答案:回答错误得分#include<stdioh>doublefun(intm){doubley=inti**************found**************for(i=i<mi)**************found**************y=(i*i)return(y)}main(){intn=printf("nTheresultislfn",fun(n))}得分详细情况如下:第处参考答案:for(i=i<=mi)考生答案:for(i=i<mi)修改错误得分第处参考答案:y=ii考生答案:y=(i*i)修改错误得分#include<stdioh>#include<stringh>#defineNvoidfun(char*s,intn,char*t){intlen,i,j=len=strlen(s)**********found**********if(n>=len)strcpy()else{**********found**********for(i=lenni<=leni)tj=**********found**********tj=}}main(){charsN,tNintnprintf("Enterastring:")gets(s)printf("Entern:")scanf("d",n)fun(s,n,t)printf("Thestringt:")puts(t)}得分详细情况如下:第空参考答案:t,s考生答案:if(n>=len)strcpy()回答错误得分第空参考答案:si考生答案:for(i=lenni<=leni)tj=回答错误得分第空参考答案:考生答案:tj=回答错误得分#include<stdioh>intfun(intm){inti,kfor(i=mi){for(k=k<ik)**************found**************if(ik!=)break**************found**************if(k<i)return(i)}}voidmain(){intnn=fun()printf("n=dn",n)}得分详细情况如下:第处参考答案:if(ik==)考生答案:if(ik!=)修改错误得分第处参考答案:if(k>=i)考生答案:if(k<i)修改错误得分#include<stdioh>#include<stringh>#include<ctypeh>intfun(char*s){char*lp,*rp**********found**********lp=rp=sstrlen(s)while((toupper(*lp)==toupper(*rp))(lp<rp)){**********found**********lprp}**********found**********if(lp<rp)elsereturn}main(){charsprintf("Enterastring:")scanf("s",s)if(fun(s))printf("n"s"isaPalindromenn",s)elseprintf("n"s"isn'taPalindromenn",s)}得分详细情况如下:第空参考答案:s考生答案:lp=回答错误得分第空参考答案:考生答案:lprp}回答错误得分第空参考答案:return考生答案:if(lp<rp)回答错误得分#include<stdioh>**************found**************fun(intn){inta=,b=,c,kdoubles=for(k=k<=nk){s=s*ab**************found**************c=aa=bb=c}return(s)}main(){intn=printf("nThevalueoffunctionis:lfn",fun(n))}得分详细情况如下:第处参考答案:doublefun(intn)考生答案:fun(intn)修改错误得分第处参考答案:c=aa=bb=c考生答案:c=aa=bb=c修改错误得分#include<stdioh>intfun(char*s){intn=,flag=while(*s!=''){if(*s!=''flag==){**********found**********flag=}**********found**********if(*s=='')flag=**********found**********}returnn}main(){charstrintnprintf("nEnteralinetext:n")gets(str)n=fun(str)printf("nTherearedwordsinthistextnn",n)}得分详细情况如下:第空参考答案:n考生答案:flag=}回答错误得分第空参考答案:考生答案:if(*s=='')flag=回答错误得分第空参考答案:s考生答案:回答错误得分#include<stdioh>#defineNintfun(float*s,intn,float*aver){floatave,t=intcount=,k,ifor(k=k<nk)**************found**************t=skave=tnfor(i=i<ni)if(si<ave)count**************found***************aver=Avereturncount}main(){floats,averintm,iprintf("nPleaseenterm:")scanf("d",m)printf("nPleaseenterdmark:n",m)for(i=i<mi)scanf("f",si)printf("nThenumberofstudents:dn",fun(s,m,aver))printf("Ave=fn",aver)}得分详细情况如下:第处参考答案:t=sk考生答案:t=sk修改错误得分第处参考答案:*aver=ave考生答案:*aver=Ave修改错误得分#include<stdioh>intfun(char*s,char*t){intn=while(*s){if(*s<){**********found***********(tn)=n}**********found**********}*(tn)=**********found**********return}main(){chars,tintnprintf("nEnterastring:n")gets(s)n=fun(s,t)printf("nTherearedletterwhichASCIIcodeislessthan:sn",n,t)}得分详细情况如下:第空参考答案:*s考生答案:*(tn)=n}回答错误得分第空参考答案:s考生答案:回答错误得分第空参考答案:n考生答案:return回答错误得分#include<stdioh>intfun(doublex,intn){************found************intj,c=,doublexa=for(j=j<nj)xa=xjnprintf("ave=fn",xa)for(j=j<nj)************found************if(xj=>xa)creturnc}main(){doublex={,,,,,,,}printf("dn",fun(x,))}得分详细情况如下:第处参考答案:intj,c=doublexa=考生答案:intj,c=,doublexa=修改错误得分第处参考答案:if(xj>=xa)考生答案:if(xj=>xa)修改错误得分#include<stdioh>#include<stringh>#include<ctypeh>intfun(char*s){intsum=while(*s){**********found**********if(isdigit(*s))sum=*s**********found**********}**********found**********return}main(){charsintnprintf("nEnterastring:nn")gets(s)n=fun(s)printf("nTheresultis:dnn",n)}得分详细情况如下:第空参考答案:考生答案:if(isdigit(*s))sum=*s回答错误得分第空参考答案:s考生答案:回答错误得分第空参考答案:sum考生答案:return回答错误得分#include<stdioh>intfun(intk){intm=,mc=while((k>=)(mc<)){************found************if((k=)||(k=)){m=mkmc}k}returnm************found************main(){printf("dn",fun())}得分详细情况如下:第处参考答案:if((k==)||(k==))考生答案:if((k=)||(k=))修改错误得分第处参考答案:}考生答案:修改错误得分#include<stdioh>#include<stringh>#include<ctypeh>voidfun(char*s){intk={},n,i,max=charchwhile(*s){if(isalpha(*s)){**********found**********ch=tolower()n=ch'a'**********found**********kn=}s**********found**********if(max<kn)max=}printf("nAftercount:n")for(i=i<i)if(ki==max)printf("nletter'c':dtimesn",i'a',ki)}main(){charsprintf("nEnterastring:nn")gets(s)fun(s)}得分详细情况如下:第空参考答案:*s考生答案:ch=tolower()回答错误得分第空参考答案:考生答案:kn=回答错误得分第空参考答案:kn考生答案:if(max<kn)max=回答错误得分#include<stdioh>#include<mathh>************found************voidfun(intk){intndoubles,w,p,qn=s=while(n<=k){w=*np=wq=ws=s*w*wpqn}************found************returns}main(){printf("fn",fun())}得分详细情况如下:第处参考答案:floatfun(intk)考生答案:voidfun(intk)修改错误得分第处参考答案:returns考生答案:returns修改错误得分#include<stdioh>#include<stringh>#defineN#defineMvoidfun(char(*ss)M){char*psN,*tpinti,j,kfor(i=i<Ni)psi=ssifor(i=i<Ni){**********found**********k=for(j=ij<Nj)**********found**********if(strlen(psk)<strlen())k=j**********found**********tp=psipsi=pskpsk=}printf("nThestringaftersortingbylength:nn")for(i=i<Ni)puts(psi)}main(){charchNM={"red","green","blue","yellow","black"}intiprintf("nTheoriginalstringnn")for(i=i<Ni)puts(chi)printf("n")fun(ch)}得分详细情况如下:第空参考答案:i考生答案:k=回答错误得分第空参考答案:psj考生答案:if(strlen(psk)<strlen())k=j回答错误得分第空参考答案:tp考生答案:tp=psipsi=pskpsk=回答错误得分#include<stdioh>#include<mathh>************found************fun(intn){doublesum,s,s,s,sintksum=if(n<=)sum=s=s=s=for(k=k<=nk){s=ssssum=sqrt(s)s=ss=ss=s}************found************returnsum}main(){intnprintf("InputN=")scanf("d",n)printf("fn",fun(n))}得分详细情况如下:第处参考答案:doublefun(intn)考生答案:fun(intn)修改错误得分第处参考答案:returnsum考生答案:returnsum修改错误得分#include<stdioh>doublef(doublex){returnx*x}doublef(doublex,doubley){returnx*y}doublefun(doublea,doubleb){**********found**********(*f)()doubler,r**********found**********f=*pointfountionf*r=f(a)**********found**********f=*pointfountionf*r=(*f)(a,b)returnrr}main(){doublex=,x=,rr=fun(x,x)printf("nx=f,x=f,x*xx*x=fn",x,x,r)}得分详细情况如下:第空参考答案:double考生答案:(*f)()回答错误得分第空参考答案:f考生答案:f=*pointfountionf*回答错误得分第空参考答案:f考生答案:f=*pointfountionf*回答错误得分#include<stdioh>#include<stdlibh>typedefstructaa{intdatastructaa*next}NODEintfun(NODE*h){intsum=NODE*p***********found**********p=hwhile(p){if(p>data==)sum=p>data***********found**********p=h>next}returnsum}NODE*creatlink(intn){NODE*h,*p,*sintih=p=(NODE*)malloc(sizeof(NODE))for(i=i<=ni){s=(NODE*)malloc(sizeof(NODE))s>data=rand()s>next=p>nextp>next=sp=p>next}p>next=returnh}outlink(NODE*h,FILE*pf){NODE*pp=h>nextfprintf(pf,"nnTHELIST:nnHEAD")while(p){fprintf(pf,">d",p>data)p=p>next}fprintf(pf,"n")}outresult(ints,FILE*pf){fprintf(pf,"nThesumofevennumbers:dn",s)}main(){NODE*headintevenhead=creatlink()head>data=outlink(head,stdout)even=fun(head)printf("nTheresult:n")outresult(even,stdout)}得分详细情况如下:第处参考答案:p=h>next考生答案:p=h修改错误得分第处参考答案:p=p>next考生答案:p=h>next修改错误得分#include<stdioh>#include<stdlibh>#defineNtypedefstructnode{intdatastructnode*next}NODEvoidfun(NODE*h){NODE*p,*qintt**********found**********p=while(p){**********found**********q=while(q){**********found**********if(p>dataq>data){t=p>datap>data=q>dataq>data=t}q=q>next}p=p>next}}NODE*creatlist(inta){NODE*h,*p,*qintih=(NODE*)malloc(sizeof(NODE))h>next=for(i=i<Ni){q=(NODE*)malloc(sizeof(NODE))q>data=aiq>next=if(h>next==)h>next=p=qelse{p>next=qp=q}}returnh}voidoutlist(NODE*h){NODE*pp=h>nextif(p==)printf("Thelistis!n")else{printf("nHead")do{printf(">d",p>data)p=p>next}while(p!=)printf(">Endn")}}main(){NODE*headintaN={,,,,,}head=creatlist(a)printf("nTheoriginallist:n")outlist(head)fun(head)printf("nThelistaftersorting:n")outlist(head)}得分详细情况如下:第空参考答案:h>next考生答案:p=回答错误得分第空参考答案:p>next考生答案:q=回答错误得分第空参考答案:>=考生答案:if(p>dataq>data)回答错误得分#include<stdioh>#include<stdlibh>typedefstructaa{intdatastructaa*next}NODEintfun(NODE*h){intmax=NODE*p***********found**********p=hwhile(p){if(p>data>max)max=p>data***********found**********p=h>next}returnmax}outresult(ints,FILE*pf){fprintf(pf,"nThemaxinlink:dn",s)}NODE*creatlink(intn,intm){NODE*h,*p,*sintih=p=(NODE*)malloc(sizeof(NODE))h>data=for(i=i<=ni){s=(NODE*)malloc(sizeof(NODE))s>data=rand()ms>next=p>nextp>next=sp=p>next}p>next=returnh}outlink(NODE*h,FILE*pf){NODE*pp=h>nextfprintf(pf,"nTHELIST:nnHEAD")while(p){fprintf(pf,">d",p>data)p=p>next}fprintf(pf,"n")}main(){NODE*headintmhead=creatlink(,)outlink(head,stdout)m=fun(head)printf("nTHERESULT:n")outresult(m,stdout)}得分详细情况如下:第处参考答案:p=h>next考生答案:p=h修改错误得分第处参考答案:p=p>next考生答案:p=h>next修改错误得分#include<stdioh>#include<stdlibh>#defineNtypedefstructnode{intdatastructnode*next}NODE**********found***********fun(NODE*h){NODE*p,*q,*rp=hif(p==)returnq=p>nextp>next=while(q){**********found**********r=q>q>next=pp=q**********found**********q=}returnp}NODE*creatlist(inta){NODE*h,*p,*qintih=for(i=i<Ni){q=(NODE*)malloc(sizeof(NODE))q>data=aiq>next=if(h==)h=p=qelse{p>next=qp=q}}returnh}voidoutlist(NODE*h){NODE*pp=hif(p==)printf("Thelistis!n")else{printf("nHead")do{printf(">d",p>data)p=p>next}while(p!=)printf(">Endn")}}main(){NODE*headintaN={,,,,}head=creatlist(a)printf("nTheoriginallist:n")outlist(head)head=fun(head)printf("nThelistafterinverting:n")outlist(head)}得分详细情况如下:第空参考答案:NODE考生答案:*fun(NODE*h)回答正确得分第空参考答案:next考生答案:r=q>回答错误得分第空参考答案:r考生答案:q=回答错误得分#include<stdioh>#include<stringh>#defineNvoidfun(char*s,chart){inti,j=for(i=i<(int)strlen(s)i)***********found**********if(isi==)tj=si***********found**********ti=''}main(){charsN,tNprintf("nPleaseenterstrings:")gets(s)fun(s,t)printf("nTheresultis:sn",t)}得分详细情况如下:第处参考答案:if(i||si==)考生答案:if(isi==)修改错误得分第处参考答案:tj=考生答案:ti=''修改错误得分#include<stdioh>#include<stdlibh>#defineNtypedefstructnode{intdatastructnode*next}NODEvoidfun(NODE*h){NODE*p,*q,*r**********found**********p=h>**********found**********if(p==)returnq=p>nextp>next=while(q){r=q>nextq>next=p**********found**********p=qq=}h>next=p}NODE*creatlist(inta){NODE*h,*p,*qintih=(NODE*)malloc(sizeof(NODE))h>next=for(i=i<Ni){q=(NODE*)malloc(sizeof(NODE))q>data=aiq>next=if(h>next==)h>next=p=qelse{p>next=qp=q}}returnh}voidoutlist(NODE*h){NODE*pp=h>nextif(p==)printf("Thelistis!n")else{printf("nHead")do{printf(">d",p>data)p=p>next}while(p!=)printf(">Endn")}}main(){NODE*headintaN={,,,,}head=creatlist(a)printf("nTheoriginallist:n")outlist(head)fun(head)printf("nThelistafterinverting:n")outlist(head)}得分详细情况如下:第空参考答案:next考生答案:p=h>回答错误得分第空参考答案:考生答案:if(p==)return回答错误得分第空参考答案:r考生答案:p=qq=回答错误得分#include<stdioh>#include<stringh>#defineNintfun(char*s,char*t){intnchar*p,*rn=while(*s){p=s*********found**********r=pwhile(*r)if(*r==*p){rp}elsebreak*********found**********if(*r=)ns}returnn}main(){charaN,bNintmprintf("nPleaseenterstringa:")gets(a)printf("nPleaseentersubstringb:")gets(b)m=fun(a,b)printf("nTheresultis:m=dn",m)}得分详细情况如下:第处参考答案:r=t考生答案:r=p修改错误得分第处参考答案:if(*r==)考生答案:if(*r=)修改错误得分#include<stdioh>#include<stdlibh>#defineNtypedefstructnode{intdatastructnode*next}NODEvoidfun(NODE*h){NODE*p,*qinttp=hwhile(p){**********found**********q=**********found**********while(){if(p>data>q>data){t=p>datap>data=q>dataq>data=t}q=q>next}**********found**********p=}}NODE*creatlist(inta){NODE*h,*p,*qintih=for(i=i<Ni){q=(NODE*)malloc(sizeof(NODE))q>data=aiq>next=if(h==)h=p=qelse{p>next=qp=q}}returnh}voidoutlist(NODE*h){NODE*pp=hif(p==)printf("Thelistis!n")else{printf("nHead")do{printf(">d",p>data)p=p>next}while(p!=)printf(">Endn")}}main(){NODE*headintaN={,,,,,}head=creatlist(a)printf("nTheoriginallist:n")outlist(head)fun(head)printf("nThelistafterinverting:n")outlist(head)}得分详细情况如下:第空参考答案:p>next考生答案:q=回答错误得分第空参考答案:q考生答案:while()回答错误得分第空参考答案:p>next考生答案:p=回答错误得分#include<stdioh>#include<ctypeh>voidfun(char*s){**********found***********while(*s!=''){if(*s>='A'*s<='Z'||*s>='a'*s<='z'){if(*s=='Z')*s='A'elseif(*s=='z')*s='a'else*s=}**********found***********(*s)}}main(){charsprintf("nEnterastringwithlength<:nn")gets(s)printf("nThestring:nn")puts(s)fun(s)printf("nnTheCords:nn")puts(s)}得分详细情况如下:第处参考答案:while(*s)考生答案:while(*s!='')修改错误得分第处参考答案:s考生答案:(*s)修改错误得分#include<stdioh>doublef(doublex){returnx*x}doublef(doublex,doubley){returnx*y}**********found**********fun(inti,doublex,doubley){if(i==)**********found**********return(x)else**********found**********return(x,y)}main(){doublex=,x=,rr=fun(,x,x)r=fun(,x,x)printf("nx=f,x=f,x*xx*x=fnn",x,x,r)}得分详细情况如下:第空参考答案:double考生答案:fun(inti,doublex,doubley)回答错误得分第空参考答案:f考生答案:return(x)回答错误得分第空参考答案:f考生答案:return(x,y)回答错误得分#include<stdioh>**********found**********charfun(char*s,char*t){intsl=,tl=char*ss,*ttss=stt=twhile(*ss){sl**********found**********(*ss)}while(*tt){tl**********found**********(*tt)}if(tl>sl)returntelsereturns}main(){chara,bprintf("nEnterastring:")gets(a)printf("nEnterastringagain:")gets(b)printf("nThelongeris:nn"s"n",fun(a,b))}得分详细情况如下:第处参考答案:char*fun(char*s,char*t)考生答案:charfun(char*s,char*t)修改错误得分第处参考答案:ss考生答案:(*ss)修改错误得分第处参考答案:tt考生答案:(*tt)修改错误得分#include<stdioh>voidfun(char*s,inta,doublef){**********found**********fpcharchfp=fopen("filetxt","w")fprintf(fp,"sdfn",s,a,f)fclose(fp)fp=fopen("filetxt","r")printf("nTheresult:nn")ch=fgetc(fp)**********found**********while(!feof()){**********found**********putchar()ch=fgetc(fp)}putchar('n')fclose(fp)}main(){chara="Hello!"intb=doublec=fun(a,b,c)}得分详细情况如下:第空参考答案:FILE*考生答案:fp回答错误得分第空参考答案:fp考生答案:while(!feof()){回答错误得分第空参考答案:ch考生答案:putchar()ch=fgetc(fp)}回答错误得分#include<stdioh>voidfun(char*s){inti,jfor(i=,j=si!=''i)if(si>=''si<='')**********found**********sj=si**********found**********sj=""}main(){charitemprintf("nEnterastring:")gets(item)printf("nnThestringis:"s"n",item)fun(item)printf("nnThestringofchangingis:"s"n",item)}得分详细情况如下:第处参考答案:sj=si考生答案:sj=si修改错误得分第处参考答案:sj=考生答案:sj=""修改错误得分#include<stdioh>#include<stdlibh>voidfun(char*s,inta,doublef){**********found**********fpcharstr,str,strintadoubleffp=fopen("filetxt","w")fprintf(fp,"sdfn",s,a,f)**********found**********fp=fopen("filetxt","r")**********found**********fscanf(,"sss",str,str,str)fclose(fp)a=atoi(str)f=atof(str)printf("nTheresult:nnsdfn",str,a,f)}main(){chara="Hello!"intb=doublec=fun(a,b,c)}得分详细情况如下:第空参考答案:FILE*考生答案:fp回答错误得分第空参考答案:fclose(fp)考生答案:回答错误得分第空参考答案:fp考生答案:fscanf(,"sss",str,str,str)回答错误得分#include<stdioh>#include<stdlibh>#include<stringh>#defineNtypedefstructss{charnumints}STUSTU*fun(STUa,intm){STUbN,*tinti,j,k**********found**********t=(STU*)calloc(sizeof(STU),m)for(i=i<Ni)bi=aifor(k=k<mk){for(i=j=i<Ni)if(bis>bjs)j=i**********found**********t(k)=b(j)bjs=}returnt}outresult(STUa,FILE*pf){intifor(i=i<Ni)fprintf(pf,"No=sMark=dn",ainum,ais)fprintf(pf,"nn")}main(){STUaN={{"A",},{"A",},{"A",},{"A",},{"A",},{"A",},{"A",},{"A",},{"A",},{"A",}}STU*pOrderinti,mprintf("*****TheOriginaldata*****n")outresult(a,stdout)printf("nGivethenumberofthestudentswhohavebetterscore:")scanf("d",m)while(m>){printf("nGivethenumberofthestudentswhohavebetterscore:")scanf("d",m)}pOrder=fun(a,m)printf("*****THERESULT*****n")printf("Thetop:n")for(i=i<mi)printf("sdn",pOrderinum,pOrderis)free(pOrder)}得分详细情况如下:第处参考答案:t=(STU*)calloc(sizeof(STU),m)考生答案:t=(STU*)calloc(sizeof(STU),m)修改错误得分第处参考答案:tk=bj考生答案:t(k)=b(j)修改错误得分#include<stdioh>#defineNtypedefstructstudent{longsnocharnamefloatscore}STUvoidfun(char*filename){FILE*fpinti,jSTUsN,t**********found**********fp=fopen(filename,)fread(s,sizeof(STU),N,fp)fclose(fp)for(i=i<Ni)for(j=ij<Nj)**********found**********if(sisnosjsno){t=sisi=sjsj=t}fp=fopen(filename,"wb")**********found**********(s,sizeof(STU),N,fp)*二进制输出*fclose(fp)}main(){STUtN={{,"ZhangSan",,,},{,"LiSi",,,},{,"CaoKai",,,},{,"FangFang",,,},{,"MaChao",,,}},ssNinti,jFILE*fpfp=fopen("studentdat","wb")fwrite(t,sizeof(STU),,fp)fclose(fp)printf("nnTheoriginaldata:nn")for(j=j<Nj){printf("nNo:ldName:sScores:",tjsno,tjname)for(i=i<i)printf("f",tjscorei)printf("n")}fun("studentdat")printf("nnThedataaftersorting:nn")fp=fopen("studentdat","rb")fread(ss,sizeof(STU),,fp)fclose(fp)for(j=j<Nj){printf("nNo:ldName:sScores:",ssjsno,ssjname)for(i=i<i)printf("f",ssjscorei)printf("n")}}得分详细情况如下:第空参考答案:"rb"考生答案:fp=fopen(filename,)回答错误得分第空参考答案:>考生答案:if(sisnosjsno)回答错误得分第空参考答案:fwrite考生答案:(s,sizeof(STU),N,fp)*二进制输出*回答错误得分#include<stdioh>#include<stringh>voidfun(chars,intn){chara,*pinti**********found***********s=pfor(i=i<ni)ai='*'do{ai=*pi}**********found***********while(*p)ai=strcpy(s,a)}main(){intncharsprintf("nEnterastring:")gets(s)printf("nThestring"s"n",s)printf("nEntern(numberof*):")scanf("d",n)fun(s,n)printf("nThestringafterinsert:"s"n",s)}得分详细情况如下:第处参考答案:p=s考生答案:s=p修改错误得分第处参考答案:while(*p)考生答案:while(*p)修改错误得分#include<stdioh>#defineNtypedefstructstudent{longsnocharnamefloatscore}STUvoidfun(char*filename,STUn){FILE*fp**********found**********fp=fopen(,"rb")**********found**********fseek(,(long)sizeof(STU),SEEKEND)**********found**********fwrite(n,sizeof(STU),,)fclose(fp)}main(){STUtN={{,"MaChao",,,},{,"CaoKai",,,},{,"LiSi",,,},{,"FangFang",,,},{,"ZhangSan",,,}}STUn={,"ZhaoSi",,,},ssNinti,jFILE*fpfp=fopen("studentdat","wb")fwrite(t,sizeof(STU),N,fp)fclose(fp)fp=fopen("studentdat","rb")fread(ss,sizeof(STU),N,fp)fclose(fp)printf("nTheoriginaldata:nn")for(j=j<Nj){printf("nNo:ldName:sScores:",ssjsno,ssjname)for(i=i<i)printf("f",ssjscorei)printf("n")}fun("studentdat",n)printf("nThedataaftermodifing:nn")fp=fopen("studentdat","rb")fread(ss,sizeof(STU),N,fp)fclose(fp)for(j=j<Nj){printf("nNo:ldName:sScores:",ssjsno,ssjname)for(i=i<i)printf("f",ssjscorei)printf("n")}}得分详细情况如下:第空参考答案:filename考生答案:fp=fopen(,"rb")回答错误得分第空参考答案:fp考生答案:fseek(,(long)sizeof(STU),SEEKEND)回答错误得分第空参考答案:fp考生答案:fwrite(n,sizeof(STU),,)回答错误得分#include<stdioh>#include<stdlibh>typedefstructaa{intdatastructaa*next}NODENODE*Creatlink(intn,intm){NODE*h=,*p,*sinti**********found***********p=(NODE)malloc(sizeof(NODE))h=pp>next=for(i=i<=ni){s=(NODE*)malloc(sizeof(NODE))s>data=rand()ms>next=p>nextp>next=sp=p>next}**********found***********returnp}outlink(NODE*h){NODE*pp=h>nextprintf("nnTHELIST:nnHEAD")while(p){printf(">d",p>data)p=p>next}printf("n")}main(){NODE*headhead=Creatlink(,)outlink(head)}得分详细情况如下:第处参考答案:p=(NODE*)malloc(sizeof(NODE))考生答案:p=(NODE)malloc(sizeof(NODE))修改错误得分第处参考答案:returnh考生答案:returnp修改错误得

用户评论(0)

0/200

精彩专题

上传我的资料

每篇奖励 +1积分

资料评分:

/151
0下载券 下载 加入VIP, 送下载券

意见
反馈

立即扫码关注

爱问共享资料微信公众号

返回
顶部

举报
资料