50道编程题答案

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

1.doublefun(STREC*a,STREC*b,int*n){inti,j;doubleave,sum=0.0;*n=0;for(i=0;iN;i++){sum+=a[i].s;}ave=sum/N;for(i=0,j=0;iN;){if(a[i].s=ave){b[j]=a[i];j++;(*n)++;}i++;}returnave;}2.voidfun(char*s,chart[]){inti=0,j=0;while(s[i]){if((i%2!=0)&&(s[i]%2!=0)){t[j]=s[i];j++;}i++;}t[j]=0;}3.intfun(char*ss,charc){intn=0,i=0;while(ss[i]){if(ss[i]==c){n++;}i++;}returnn;}4.voidfun(char*a){inti=0,j=0;while(a[i]){if(a[i]!='*'){j=i;break;}i++;}while(a[i]){a[i-j]=a[i];i++;}a[i-j]='\0';}5.voidfun(chara[],charb[],intn){inti=0,j=0;while(a[i]){if(i!=n){b[j]=a[i];j++;}i++;}b[j]='\0';}6.char*fun(char*s,char*t){char*m,*n;m=s;n=t;while(*s&&*t){t++;s++;}if(*t)returnn;elsereturnm;}7.voidfun(char*a,char*h,char*p){inti=0;for(;a[i]=='*';i++)a[i]='*';while(hp){if(*h!='*'){a[i]=*h;i++;}h++;}while(*h){a[i]=*h;i++;h++;}a[i]='\0';}8.voidfun(STRECa[]){inti,j;STRECb;for(i=0;iN-1;i++)for(j=i+1;jN;j++)if(a[i].sa[j].s){b=a[i];a[i]=a[j];a[j]=b;}}9.longfun(char*p){longi,s=0;if(p[0]=='-'){i=1;while(p[i]){s=s*10+p[i]-'0';i++;}s*=-1;}else{i=0;while(p[i]){s=s*10+p[i]-'0';i++;}}returns;}10.voidfun(charp1[],charp2[]){char*p,*q;p=p1;q=p2;while(*p)p++;while(*q)*p++=*q++;*p='\0';}11.voidfun(char*a){charp[81];inti=0,j=0;while(a[i]){if(a[i]!='*')a[j++]=a[i];i++;}a[j]=0;}12.voidfun(intm,int*k,intxx[]){inti,j,c=0;for(i=2;i=m;i++){for(j=2;ji;j++)if(i%j==0){xx[c]=i;c++;break;}}*k=c;}13.*c=a/10+a%10*100+b%10*10+b/10*1000;14.intfun(STREC*a,STREC*b){inti,j=0,s=a[0].s;for(i=1;iN;i++)if(a[i].ss)s=a[i].s;for(i=0;iN;i++)if(a[i].s==s){b[j]=a[i];j++;}returnj;}15.voidfun(char*a){inti=0,j=0;while(a[i]){if(j==0&&a[i]!='*'){j=i+1;}elseif(a[i]!='*'){a[j]=a[i];j++;}i++;}a[j]=0;}16.intfun(inta[][M]){inti,j,max=0;for(i=0;i2;i++)for(j=0;jM;j++){if(maxa[i][j])max=a[i][j];}returnmax;}17voidfun(int*a,int*n){inti=0,j=0;*n=0;for(;i=1000;i++){if(i%7==0||i%11==0){if(i%7==0&&i%11==0)continue;(*n)++;a[j++]=i;}}return*n;}18voidfun(STREC*a){inti=0;doublesum=0.0;for(;iN;i++){sum+=a-s[i];}a-ave=sum/N;}19voidfun(inta,intb,long*c){*c=a/10*100+a%10+b/10*1000+b%10*10;}20,doublefun(){floatx0,x1=0.0;while(1){x0=x1;x1=cos(x0);if(fabs(x0-x1)1e-6)break;}returnx1;}21.voidfun(char*a,intn){inti=0,j=0,c,k;while(a[i])i++;c=i;while(a[i-1]=='*'){j++;i--;}if(jn){k=j-n;a[c-k]='\0';}}22.voidfun(char*s,chart[]){inti=0,j=0,m;while(m=s[i]){if(m%2==0){t[j]=s[i];j++;}i++;}t[j]='\0';}23.doublefun(doubleeps){inti=0;doublepi=0,a=1;while(a=eps){pi+=a;i++;a=a*i/(2*i+1);}returnpi*2;}24.voidfun(char*tt,intpp[]){inti;for(i=0;i26;i++)pp[i]=0;i=0;while(tt[i]){pp[tt[i]-97]++;i++;}}25.voidfun(char*s,chart[]){inti=0,k=0,length;length=strlen(s);while(ilength){if(i%2==0&&s[i]%2==0){t[k]=s[i];k++;i++;}elsei++;}t[k]='\0';}26.intfun(intt){inta=1,b=1,c=0,i;for(i=4;i=t;i++){if(ct){c=a+b;a=b;b=c;}elsebreak;}returnc;}27voidfun(char*a){while(*a!=NULL)a++;a--;while(*a=='*')a--;a++;*a='\0';}28.voidfun(inta,intb,long*c){*c=a/10*100+a%10+b/10*10+b%10*1000;}29.voidfun(intm,int*a,int*n){inti,j;*n=0;for(i=1,j=0;i=m;i++){if((i%7==0)||(i%11==0)){a[j]=i;j++;(*n)++;}}}30.doublefun(STREC*h){doublemax;STREC*p;p=h-next;max=p-s;while(p){if(p-smax){max=p-s;}p=p-next;}returnmax;}31.voidfun(inta[3][3],intb[3][3]){inti,j;for(i=0;i3;i++)for(j=0;j3;j++)b[i][j]=0;for(i=0;i3;i++)for(j=0;j3;j++)b[i][j]=a[i][j]+a[j][i];}32intfun(STREC*a,STREC*b){inti,j=0,score;score=a[0].s;for(i=0;iN;i++)if(scorea[i].s)score=a[i].s;for(i=0;iN;i++)if(score==a[i].s){strcpy(b[j].num,a[i].num);b[j].s=a[i].s;j++;}returnj;}33voidfun(inta[],intn,int*max,int*d){inti,j,k=0;i=a[0];for(j=0;jn;j++)if(ia[j]){i=a[j];k=j;}*max=i;*d=k;}34doublefun(STREC*h){floatave,sum=0.0;STREC*p;p=h-next;while(p){sum+=p-s;p=p-next;}ave=sum/N;returnave;}35voidfun(char*s,chart[]){inti;for(i=0;i50;i++)t[i]=s[2*i+1];}36.voidfun(char*ss){inti=0;while(ss[i]){if(i%2!=0){if(ss[i]='a'&&ss[i]='z'){ss[i]-=32;}}i++;}}37.floatfun(float*a,intn){inti;doublesum=0.0,ave;for(i=0;in;i++)sum+=a[i];ave=sum/n;returnave;}38.voidfun(inta,intb,long*c){*c=a/10*1000+a%10*10+b/10*100+b%10;}39.doublefun(intm){inti=1;doublesum=0.0;for(;i=20;i++){sum=sum+log(i);}sum=sqrt(sum);returnsum;}40.voidfun(char*a,char*p){char*q;while(ap)if(*a=='*'){for(q=a;*q;q++)*q=*(q+1);p--;}elsea++;}41、doublefunc(intn){inti,j;floatsum,resu;resu=0;for(i=1;i=n;i++){sum=0;for(j=1;j=i;j++){sum=sum+j;}resu=resu+1/sum;}returnresu;}42、voidfunc(char*a){char*p,*q;intn=0;p=a;while(*p=='*'){n++;p++;}q=a;while(*p!=NULL){*q=*p;p++;q++;}for(;n0;n--){*q++='*';}*q='\0';}43、voidfunc(char*a,intn){inti=0,j=0;while(a[i]){if(a[i]!='*'){j=i;break;}i++;}if(jn){while(a[i]){a[i-j+n]=a[i];i++;}a[i-j+n]=0;}}44.voidfun(inta,intb,long*c){*c=a/10*10+a%10*1000+b/10*100+b%10;}45.voidfun(inta,intb,long*c){*c=a/10*1000+a%10*10+b/10+b%10*100;}46.voidfun(inta,intb,long*c){*c=a/10+a%10*100+b/10*10+b%10*1000;}47.intfun(STREC*a,STREC*b,intl,inth){inti,j=0;for(i=0;iN;i++){if(a[i].s=l&&a[i].s=h){b[j]=a[i];j++;}}returnj;}48.STRECfun(STREC*a,char*b){STRECres;inti;for(i=0;iN;i++){if(strcmp(a[i].num,b)==0){res=a[i];returnres;}}strcpy(res.num,);res.s=-1;

1 / 19
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功