版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
第1套题ー、程序填空题#include<stdio.h>#include<stdlib.h>#defineN5typedefstruct{intnum;charname[10];chartel[10];JSTYPE;voidcheck();/**********found**********/intfun( 1 *std)/*******************/一2-*fp;inti;if((fp=fopen(',myfile5.dat,,,,,wb,,))==NULL)return(O);printf(M\nOutputdatatofile!\n'*);for(i=0;i<N;i++)/**********j'ioiind**********/fwrite(&std[i],sizeof(STYPE),1,—3—);fclose(fp);return(1);)main(){STYPEs[10]={{1,“aaaaa”,”11111ド},{IJbbbbb”,”222222"},“Jccccc”,”333333”},{1;,ddddd',,M444444,,},{l;,eeeee";,555555*,});intk;k=fun(s);if(k==l){printf("Succeed!H);check();}elseprintf("Fail!H);voidcheck(){FILE*fp;inti;STYPEs[10];if((fp=fopen("myfile5.dat',;,rb,,))==NULL){printf("Fail!!\nH);exit(O);}printf("\nReadfileandoutputtoscreen:\nM);printf(u\nnumnametel\nu);for(i=0;i<N;i++){fread(&s|i],sizeof(STYPE),l,fp);printf(M%6d%s %s\nM,s[i].num,s[i].name,s[i].tel);}fclose(fp);二、程序改错题#include<stdio.h>#include<string.h>voidfun(char*s,char*t){inti,si;si=strlen(s);***********found************/fbr(i=0;i<=sl;i++)t[i]=s[i];for(i=0;i<sl;i++)t[sl+i]=s[sl-i-l];t[sl]=,〇';main(){chars[100],t[100|;printf("\nPleaseenterstrings:H);scanf("%s",s);fun(s,t);printf("Theresultis:%s\n",t);三、程序编写题#include<stdio.h>voidfun(inta,intb,long*c))main(){inta,b;longc;voidNONO();printf("Inputab:");scanf("%d%d",&a,&b);fun(a,b,&c);printf(MTheresultis:%d\nM,c);NONO();)voidNONO(){/・本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。*/FILE*rf,*wf;inti,a,b;longc;rf=fopen(''KiWkO1W24010001Win.dat*',HrH);wf=fopen("K:\\kO1W24010001Wout.dat",HwH);for(i=0;i<10;i++){fscanf(rf,M%d,%d",&a,&b);fun(a,b,&c);fprintf(wf,"a=%d,b=%d,c=%ld\n",a,b,c);)fclose(rf);fclose(wf);第2套题ー、程序填空题#include<stdio.h>#include<string.h>#include<stdlib.h>voidWriteText(FILE*);voidReadText(FILE*);main(){FILE*fp;if((fp=fopen("myfile4.txt";,w"))==NULL){printf("openfail!!\n");exit(O);}WriteText(fp);fclose(fp);if((fp=fopen("myfile4.txt",Hr"))=NULL){printf("openfail!!\n");exit(O);}ReadText(fp);fclose(fp);)/**********found**********/voidWriteText(FILE―1—){charstr[81];printf(H\nEnterstringwith-1toend:\n");gets(str);while(strcmp(str,,,-l,,)!=O){/**********found**********/iputs( 2 ,fw);fputs(ヽn”,fw);gets(str);))voidReadText(FILE*fr){charstr[81];printf(M\nReadfileandoutputtoscreen:\n,r);fgets(str,81,fr);while(!feof(fr)){/**********d**********/printf(M%sM,__3_);fgets(str,81,fr);)二、程序改错题#include<stdio.h>/************fiound************/voidfun(longs,longt){longsl=10;*t=s%10;while(s>0){s=s/100;*t=s%10*si+*t;***********tound************/si=si*100;}main(){longs,t;printf(*'\nPleaseenters:,r);scanf(H%idn,&s);fun(s,&t);printf(HTheresultis:%ld\n]。;三、程序编写题#include<stdio.h>#defineN16typedefstruct{charnum(10];ints;}STREC;intfun(STREC*a,STREC*b)main(){STRECs[N]={{nGA05n,85},{HGA03n,76},{,,GA02,',69},{nGA04M,85),{“GAO「’,91},{"GA07",72},{"GA08",64},{"GA06",87),{"GA015",85},{"GA013",91},{"GA012",64},{"GA014",91},{"GA011",91},{"GA017",64},{"GA018",64},{"GA016",72}};STRECh[N];inti,n;FILE*out;n=fun(s,h);printf("The%dlowestscore:\n",n);for(i=0;i<n;i++)printf("%s%4d\n",h[i].num,h[i].s);printf("\n");out=fopen("K:\\k01\\24010001\\out.dat","w");fprintf(out,"%d\n",n);for(i=0;i<n;i++)fprintf(out,"%4d\n",h[i].s);fclose(out);第3套题ー、程序填空题#include<math.h>#include<stdio.h>intfun(char*fname){FILE*fp;inti,n;floatx;if((fp=fopen(fname,"w"))=NULL)return0;for(i=l;i<=10;i++)/**********砧und**********/fprintf(_1__J%d%t\nu,i,sqrt((double)i));printfC'nSucceed!!\nn);/**********tound**********/一2一;printfVAnThedatainfile:\nH);/**********ほund*东辛*******/if((fp=fopen(—3—;,r,,))==NULL)return0;fscanf(fp/'%d%f;&n,&x);while(!feof(fp)){printf(f,%d%ftn';n,x);fscanf(fp/%d%f';&n?&x);}fclose(fjp);return1;main(){charfname[]=Mmyfile3.txtM;fun(fname);)二、程序改错题#include<stdio.h>#include<stdlib.lr>voidfun(intn,int*a){inti,j,p,t;for(j=0;j<n-l;j++){P=j;/************fbund************/for(i=j+l;i<n-l;i++)if(a[p]>a[i])/************found************/t=i;if(p!=j){t=a[j];a[j]=a[p];a[p]=t;}voidputarr(intntint*z){inti;for(i=1;i<=n;i++,z++){printf(M%4d",*z);if(!(i%10))printf(}printf(AnM);)main(){intaa[20]={9,3,0,4,1,2,5,6,8,10,7},n=l1;printf(H\n\nBefbresorting%dnumbersAn*',n);putarr(n,aa);fun(n,aa);printf(M\nAftersorting%dnumbers:\nM,n);putarr(n,aa);)三、程序编写题#include<stdio.h>voidfbn(inta,intb,long*c)main(){inta,b;longc;voidNONO();printf("Inputab:");scanf("%d%d",&a,&b);fun(a,b,&c);printf("Theresultis:%ld\n",c);NONO();)voidNONO(){/・本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。*/HLE*rf,*wf;inti,a,b;longc;rf=fopen("K:\\k01\\24010001\\in.dat","r");wf=fopen("K:\\k01W24010001Wout.dat","w");for(i=0;i<10;i++){fscanf(rf,u%d,%d",&a,&b);fiin(a,b,&c);fprintf(wf,"a=%d,b=%d,c=%ld\n",a,b,c);)fclose(rf);fclose(wf);第4套题ー、程序填空题#include<stdio.h>#include<stdlib.h>intfun(char*source,char*target){FILE charch;/**********found**********/if((fs=fopen(source, 1 ))==NULL)return0;if((ft=fopen(target,,,w',))==NULL)return0;printf("\nThedatainfile:\nu);ch=fgetc(fs);/**********^Qund**********/while(!feof( 2 )){putchar(ch);/**********tound**********/fputc(ch, 3 );ch=fgetc(fs);}fclose(fs);fclose(ft);printf(,,\n\nu);return1;)main(){charsfname[20]="myfHe「',tfname[20]="myfile2";FILE*myf;inti;charc;myf=fbpen(sfname,"wu);printf(H\nTheoriginaldata:\nM);for(i=l;i<30;i++){c='A'+rand()%25;fprintf(myf,"%c",c);printf(,,%c,',c);}fclose(myf);printf(An\n'*);if(fun(sfname,tfname))printf("Succeed!”);elseprintf(^'Fail!,^);二、程序改错题#include<stdio.h>voidfun(longs,long*t){intd;longsl=l;*t=0;while(s>0){d=s%10;/************found************/if(d%2=0){*t=d*sl+*t;si*=10;/************f^ound************/s\=10;)}main(){longs,t;printf(H\nPleaseenters:1');scanf("%ld'\&s);fun(s,&t);printf(uTheresultis:%ld\n",t);}三、程序编写题#include<stdio.h>#include<string.h>voidfiin(char*s,chart[])}main(){chars[100],t[100];voidNONO();printf("\nPleaseenterstringS:");scanf("%s",s);fun(s,t);printf("\nTheresultis:%s\n",t);NONO();voidNONO(){/・本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。*/chars[100],t[100];FILE*rf,*wf;inti;rf=fopen("K:\\k01\\240100OIWin.daピ,ケ“);wf=fopen(nK:\\kO1W24010001Wout.dat",nwu);for(i=0;i<10;i++){fscanf(rf,M%sM,s);fun(s,t);fprintf(wf,n%s\nH,t);)fclose(rf);fclose(wf);第5套题ー、程序填空题#include<stdio.h>#include<stdlib.h>#defineN8typedefstructlist{intdata;structlist*next;}SLIST;voidfun(SLIST*h,intx){SLIST*p,*q,*s;s=(SLIST*)malloc(sizeof(SLIST));/**********Cund**********/s->data=q=h;p=h->next;while(p!=NULL&&x>p->data){/**********fiound**********/q= 2 ;p=p->next;}s->next=p;/**********found**********/q->next= 3 SLIST*creatlist(int*a){SLIST*h,*p,*q;inti;h=p=(SLIST*)malloc(sizeof(SLIST));for(i=0;i<N;i++){q=(SLIST*)malloc(sizeof(SLIST));q->data=a[i];p->next=q;p=q;}p->next=0;returnh;voidoutlist(SLIST*h){SLIST*p;p=h->next;if(p==NULL)printf("ヽnThelistisNULL!\nM);else{printf(AnHeadu);do{printf("->%dH,p->data);p=p->next;}while(p!=NULL);printf(H->End\nM);)main(){SLIST*head;intx;inta[N]={11,12,15,18,19,22,25,29);head=creatlist(a);printf("\nThelistbeforeinserting:\n");outlist(head);printf(H\nEnteranumber:");scanf(*'%dn,&x);fun(head,x);printf("ヽnThelistafterinserting:\n");outlist(head);二、程序改错题#include<stdio.h>longfun(longnum)/************ nd************/longk;do{k*=num%10;/************found************/num\=10;}while(num);return(k);main(){longn;printf(K\nPleaseenteranumber:M);scanf(M%ld'\&n);printf("\n%ld\n,\fun(n));三、程序编写题#include<stdio.h>floatfun(float*a,intn)main(){floatscore[30]={90.5,72,80,61.5,55),aver;voidNONO();aver=fun(score,5);printf(AnAveragescoreis:%5.2f\n",aver);NONO();)voidNONO(){/・本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。*/FILE*fp,*wf;inti,j;floataver,score(5];fp二fopen("K:\\kOI\\24010001Win.dat",“r“);wf=fopen(”K:\\k01\\24010001Wout.dat",““);for(i=0;i<10;i++){for(j=0;j<5;j++)fscanf(fp,H%f,*',&score|j]);aver=fun(score,5);fprintf(wf,H%5.2f\nn,aver);}fclose(fp);fclose(wf);第6套题、程序填空题#include<stdio.h>#include<stdlib.h>#defineN8typedefstructlist{intdata;structlist*next;}SLIST;voidftin(SLIST*p){SLIST*t,*s;t=p->next;s=p;while(t->next!=NULL){S=t;/**********found**********/t=t-> 1 ;)/**********j'ioiind**********/printf(“%d”,—2—);s->next=NULL;/*******************/free( 3 );)SLIST*creatlist(int*a){SLIST*h,*p,*q;inti;h=p=(SLIST*)malloc(sizeof(SLIST));for(i=0;i<N;i++){q=(SLIST*)malloc(sizeof(SLIST));q->data=a[i];p->next=q;p=q;)p->next=0;returnh;voidoutlist(SLIST*h){SLIST*p;p=h->next;if(p==NULL)printf("\nThelistisNULL!\nH);else{printf(,'\nHead,');do{printf(n->%dM,p->data);p=p->next;}while(p!=NULL);printf(H->End\nM);)main(){SLIST*head;inta[N]={11,12,15,18,19,22,25,29);head=creatlist(a);printf(K\nOutputfromheadAn1');outlist(head);printf("\nOutputfromtail:\nn);while(head->next!=NULL){fun(head);printf(An\nu);printf('ヽnOutputfromheadagain:\n");outlist(head);)二、程序改错题#include<stdio.h>fun(chara){if(*a){fun(a+l);/************ nd************/printf(M%c"*a);})main(){chars[10]=MabcdM;primf("处理前字符串二%s\n处理后字符串ビ,s);fun(s);printf("、ゴ);三、程序编写题#include<stdio.h>char*fun(char*s,char*t)main(){chara[20],b[20];voidNONO();printf(HInput1thstring:*');gets(a);printf("Input2thstring:");gets(b);printf("%s\n",fun(a,b));NONO();)voidNONO(){/・本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。*/FILE*fp,*wf;inti;chara[20],b[20];fp=fopen("K:\\k01\\24010001\\in.dat","r");wf=fbpen("K:WkO1W24010001Wout.dat","w");for(i=0;i<10;i++){fscanf(fp,"%s%s",a,b);fprintf(wf,"%s\n",fun(a,b));}fclose(fp);fclose(wf);)第7套题ー、程序填空题#include<stdio.h>#include<stdlib.h>#defineN8typedefstructlist{intdata;structlist*next;}SLIST;voidfun(SLIST*h){SLIST*p,*q;p=h->next;if(p!=NULL){q=p->next;while(q!=NULL){if(p->data==q->data){p->next=q->next;/**********^Qund**********/free( 1 );/**********tound**********/q=p->_2_;elseq=q-> 3 ;}}))SLIST*creatlist(int*a){SLIST*h,*p,*q;inti;h=p=(SLIST*)malloc(sizeof(SLIST));for(i=0;i<N;i++){q=(SLIST*)malloc(sizeof(SLIST));q->data=a[i];p->next=q;p=q;}p->next=0;returnh;}voidoutlist(SLIST*h){SLIST*p;p=h->next;if(p==NULL)printfCAnThelistisNULL!\nM);else{printf(n\nHead");do{printf(M->%d",p->data);p=p->next;}while(p!=NULL);printf("・>End\n");}}main(){SLIST*head;inta[N]={1,2,234,4,4,5};head=creatlist(a);printf("\nThelistbeforedeleting:\nM);outlist(head);fun(head);printf(ヽnThelistafterdeleting:\nH);outlist(head);二、程序改错题#include<stdio.h>#defineN20voidfun(inta[],intn){inti,j,t,p;for(j=0;j<n-1;j++){]************found************/P=jfor(i=j+l;i<n;i++)if(a[i]<a[p])/************found************/P=J;t=a[p];a[p]=a[j];a[j]=t;main()inta[N]={9,6,8,3,-l},i,m=5;printf("排序前的数据:“);for(i=0;i<m;i++)printf(H%dM,a(i]);printf("\nn);fun(a,m);printf("排序后的数据:");for(i=0;i<m;i++)printf("%d",a[i]);printf("\n");三、程序编写题#include<stdio.h>#defineM100voidfun(intm,int*a,int*n)main(){intaa[M],n,k;voidNONO();fun(50,aa,&n);for(k=0;k<n;k++)if((k+l)%20==0)printf(n\nn);elseprintf(M%4dM,aa[k]);printf('^\n,^);NONO();voidNONO(){/・本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。*/FILE*fp,*wf;inti,n,j,k,aa[M],sum;fp二fopen("K:\\k01\\240100OIWin.dae',ケ“);wf二fopen("K:\\k01\\24010001\\out.da「"w”);for(i=0;i<10;i++){fscanf(fp,"%d;;&j);fun(j,aa,&n);sum=0;for(k=0;k<n;k++)sum+=aa[k];fprintf(wf,M%d\nM,sum);}fclose(fp);fclose(wf);第8套题ー、程序填空题#include<stdio.h>#include<stdlib.h>#defineN8typedefstructlist{intdata;structlist*next;}SLIST;SLIST*creatlist(char*);voidoutlist(SLIST*);intfun(SLIST*h,charch){SLIST*p;intn=0;p=h->next;/******************/while(p!= 1 ){n++;/**********found**********/if(p->data==ch)return 2 ;elsep=p->next;)return0;)main(){SLIST*head;intk;charch;chara[N]={,m,;pVg,;a7w','xVr,;d,);head=creatlist(a);outlist(head);printf("Enteraletter:");scanf("%c'\&ch);/**********found**********/k=fun(—3-);if(k==0)printf("\nNotfound!\n");elseprintf("Thesequencenumberis:%d\n",k);)SLIST*creatlist(char*a){SLIST*h,*p,*q;inti;h=p=(SLIST*)malloc(sizeof(SLIST));for(i=0;i<N;i++){q=(SL!ST*)malloc(sizeof(SLIST));q->data=a[i];p->next=q;p=q;}p->next=0;returnh;)voidoutlist(SLIST*h){SLIST*p;p=h->next;if(p==NULL)printf("\nThelistisNULL!\nM);else{printf("\nHead");do{printf("->%c°,p->data);p=p->next;}while(p!=NULL);printf(',->End\n,');}二、程序改错题#include<string.h>#include<stdio.h>#include<ctype.h>fun(char*p){inti,t;charc[80|;For(i=0,t=0;p[i];i++)if(!isspace(*(p+i)))c[t++]=p[i];]************found************/c[t]="\On;strcpy(p,c);main(){charc,s[80];inti=0;printf("Inputastring:");c=getchar();while(c!=,#t){s[i]=c;i++;c=getchar();}s[i]=\O,;fun(s);puts(s);}三、程序编写题#include<stdio.h>#include<string.h>voidfun(char*ss)main(){chartt[81];voidNONO();printf("\nPleaseenteranstringwithin80characters:\n");gets(tt);printf("\n\nAfterchanging,thestring\n\"%s\n",tt);fun(tt);
printf(',\nbecomes\nヽ"%s\"\n",tt);NONO();)voidNONO(){/・本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。*/FILE*fp,*wf;chartt[81];inti;fp=fopen("K:\\k01\\24010001\\in.dat,',,,rn);wf=fopen(nK:\\kO1W24010001Wout.dat",nwM);for(i=0;i<10;i++){fscanf(fp,"%s",tt);fun(tt);fprintf(wf,"%s\n",tt);)fclose(fp);fclose(wf);)第9套题ー、程序填空题#include#include<stdio.h><stdlib.h>#include#include<stdio.h><stdlib.h>#definetypedefN8
structlist{intdata;structlist*next;)SLIST;SLIST*creatlist(int*a);voidoutlist(SLIST*);voidfun(SLIST*h,int*n){SLIST*p;/**********found**********/—1—=0;p=h->next;while(p){(*n)++;/********** d**********/p=p-> 2 ;))main(){SLIST*head;inta[N]={12,87,45,32,91,16,20,48},num;head=creatlist(a);outlist(head);/**********tound**********/fun( 3 ,&num);printf("\nnumber=%d\nn,num);)SLIST*creatlist(inta[]){SLIST*h,*p,*q;inti;h=p=(SLIST*)malloc(sizeof(SLIST));for(i=0;i<N;i++){q=(SLIST*)malloc(sizeof(SLIST));q->data=a[i];p->next=q;p=q;)p->next=0;returnh;}voidoutlist(SLIST*h){SLIST*p;p=h->next;if(p==NULL)printf(MThelistisNULLln");else{printf("ヽnHead");do{printf(,'->%d,',p->data);p=p->next;}while(p!=NULL);printf(H->End\nM);))二、程序改错题#include<stdio.h>#include<string.h>char*fun(char*s,char*t){char*p,*r,*a;/************found*******司a=Null;while(*s){p=s;r=t;while(*r)/************nd************/if(r==p){r++;P++;}elsebreak;if(*r==、〇')a=s;s++;returna;main()chars[100Lt[100],*p;printf(n\nPleaseenterstringS:M);scanf("%s",s);printf("\nPleaseentersubstringt:M);scanf("%s",t);p=fun(s,t);if(p)printf(ヽnTheresultis:%s\n",p);elseprintfC'nNotfound!\nM);三、程序编写题#include<stdio.h>voidfun(inta,intb,long*c)Imain(){inta,b;longc;voidNONO();printf("Inputab:");scanf("%d%d",&a,&b);fun(a,b,&c);printf("Theresultis:%ld\n",c);NONO();)voidNONO(){/・本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。*/FILE*rf,*wf;inti,a,b;longc;rf=fopen(,'K:\\k01\\24010001\\in.datn,Hr");wf=fopen(nK:WkO1W24010001Wout.datu,uwH);for(i=0;i<10;i++){fscanf(rf,"%d,%d“,&a,&b);fun(a,b,&c);fprintf(wf,,,a=%d,b=%d,c=%ld\n'\a,b,c);)fclose(rf);fclose(wf);第10套题ー、程序填空题#include<stdio.h>#include<stdlib.h>#defineN8typedefstructlist{intdata;structlist*next;}SL1ST;SLIST*creatlist(int*);voidoutlist(SLIST*);intfun(SLIST*h){SLIST*p;ints=0;p=h->next;while(p)/**********found**********/s+=p-> 1 ;/**********fiound**********/p=p-> 2 ;)returns;)main(){SLIST*head;inta[N]={12,87,45,32,91,16,20,48);head=creatlist(a);outlist(head);/******************/printf(,,\nsum=%d\nM,fun( 3 ));SLIST*creatlist(inta[]){SLIST*h,*p,*q;inti;h=p=(SLIST*)malloc(sizeof(SLIST));for(i=0;i<N;i++){q=(SLIST*)malloc(sizeof(SLIST));q->data=a[i];p->next=q;p=q;}p->next=O;returnh;)voidoutlist(SLIST*h){SLIST*p;p=h->next;if(p==NULL)printf('ThelistisNULL!\nM);else{printf("\nHeadn);do{printf(',->%d,',p->data);p=p->next;}while(p!=NULL);printf(H->End\n");))二、程序改错题#include<stdio.h>#include<string.h>voidfun(char*s,char*tl,char*t2,char*w){char*p,*r,*a;strcpy(w,s);while(*w){p=w;r=tl;while(r)if(*r==*p){r++;p++;)elsebreak;if(*r=\O'){a=w;r=t2;while(*r){*a=*r;a++;r++)w+=strlen(t2);)elsew++;))main()(chars|100|,tl[100],t2[l(X)Lw|100];printf(M\nPleaseenterstringS:M);scanf(,'%s1',s);printf("\nPleaseentersubstringscanf(M%sM,tl);printf(u\nPleaseentersubstring⑵");scanf(M%sM,t2);if(strlen(tl)==strlen(t2)){fun(s,tl,t2,w);printf('ヽnTheresultis:%s\n",w);)elseprintf("Error:strlen(tl)!=strlen(t2)\n");三、程序编写题#include<stdio.h>#include<string.h>voidfun(char*s,chart[]))main()(chars[100Lt[100];voidNONO();printf("\nPleaseenterstringS:");scanf("%s",s);fun(s,t);printf("\nTheresultis:%s\n",t);NONO();voidNONO(){/・木函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。*/chars[100],t[100];FILE*rf,*wf;inti;rf=fopen("K:\\k(H\\240100OIWin.daビ,”ド);wf=fopen(,,K:\\k01\\24010001\\out.dat,,,',wH);for(i=0;i<10;i++){fscanf(rf,n%sM,s);fun(s,t);fprintf(wf,"%s\n'',t);)fclose(rf);fclose(wf);第11套题ー、程序填空题#include<stdio.h>#include<string.h>#define M 5#define N 20intfun(char(*ss)[N],int*n){inti,k=0,len=N;/**********found^*********/for(i=0;i<_1—;i++){len=strlen(ss[i]);if(i=0)*n=len;/**********found**********/if(len—2_*n){*n=len;k=i;})/**********砧]]nd**********/retum( 3 );)main(){charss[M][N]:{"shanghai","guangzhou","be帀ng”Jtianjing","chongqing");intn,k,i;printf(u\nTheoriginalstringsare:\nM);for(i=0;i<M;i++)puts(ss[i]);k=fun(ss,&n);printf(AnThelengthofshorteststringis:%d\nM,n);printf('ヽnTheshorteststringis:%s\n'\ss[k]);)二、程序改错题#include<stdio.h>#include<string.h>char*fun(chartt(])(inti;for(i=0;tt[i];i++)/**********found***********/if(('a'<=tt[i])11(tt[i]<=Y))/**********found***********/tt[i]+=32;return(tt);)main()(chartt[81];printf(M\nPleaseenterastring:");gets(tt);printf("\nTheresultstringis:\n%sM,fun(tt));三、程序编写题#include<stdio.h>intprime(intm){intk=2;while(k<=m&&(m%k))k++;if(m==k)return1;elsereturn0;voidfun(intm,int*k,intxx[])main()(intm,n,zz[100];voidNONO();printf(M\nPleaseenteranintegernumberbetween10and100:n);scanf("%d",&n);fun(n,&m,zz);printf('へn'nThereare%dnon-primenumberslessthan%d:",m,n);for(n=0;n<m;n++)printf(**\n%4d",zz[n]);NONO();)voidNONO()(/・请在此函数内打开文件,输入测试数据,调用fun函数,输出数据,关闭文件。・/intm,n,zz|100|;FILE*rf,*wf;rf=fopen("K:\\k01\\240100OIWin.daビJr“);wf=fopen(MK:\\kO1W2401000lWout.dat'\"wn);fscanf(rf,"%d",&n);fun(n,&m,zz);fprintf(wf,M%d\n%d\nM,m,n);for(n=0;n<m;n++)fprintf(wf,"%d\n”,zz[n]);fclose(rf);fclose(wf);}第12套题ー、程序填空题#include<stdio.h>voidfun(char水s){inti,j=0,k=0;chartl[80],t2[80];for(i=0;s[i]!=W;i++)if(s[i]>='0"&&s[i]<=r9r)/****や氷*字**'found*・累宇・・ネ・・ネ/t2[j]=s[i];—1—;)elsetl[k++]=s[i];t2|j]=0;tl[k]=O;/****申字东东な*d条・窓密・**咏东率]for(i=0;ivk;i++) 2 ;辛・・密・东米・泳fiDiindキ*キ*****寧//for(i=0:i< 3 ;i++)s[k+i]=t2[i];main(){chars[80]="def35adh3kjsdf7M;printf("ヽnTheoriginalstringis:%s\nH,s);fun(s);printf(u\nTheresultis:%s\n'\s);二、程序改错题#include<stdio.h>#include<string.h>#defineMAXLINE20fun(char*pstr[6]){inti,j;char*p;for(i=0;i<5;i++){************率found***木*來******求*/for(j=i+1,j<6,j++)if(strcmp(*(pstr+i),*(pstr+j))>0)p=*(pstr+i);・ホホ・本・*藤****申^^ju1idホ ホキ东**东*小本**/*(pstr+i)=pstr+j;*(pstr+j)=p;))}main(){inti;char*pstr[6],str[6][MAXLINE];for(i=0;i<6;i++)pstrfi]=str[i];printf("\nEnter6string(1stringateachline):\n");for(i=0;i<6;i++)scanf(M%sM,pstr[i]);fun(pstr);printf(MThestringsaftersorting:\nH);fbr(i=0;i<6;i++)printf(,,%s\n,',pstr[i]);三、程序编写题#include<stdio.h>#include<string.h>#defineM81intfun(char*ss,charc))main(){chara[M],ch;voidNONO();printf("\nPleaseenterastring:'1);gets(a);printf("\nPleaseenterachar:");ch=getchar();printf("\nThenumberofthecharis:%d\n",fun(a,ch));NONO();voidNONO(){/・本函数用于打开文件,输入测试数据,调用fun函数,输出数据,关闭文件。*/inti;FILE*rf,*wf;chara[M],b[M],ch;rf=fopen("K:\\k01\\240100OIWin.daピ,丁’);wf=fopen(nK:\\kO1W24010001Wout.dat","w");for(i=0;i<10;i++){fscanf(rf,M%s",a);fscanf(rf,"%s",b);ch=*b;fprintf(wf,"%c=%d\n",ch,fun(a,ch));)fclose(rf);fclose(wf);第13套题ー、程序填空题#include<stdio.h>voidfun(char*s){inti,j,n;for(i=0;s[i]!=\0';i-H-)/********** d**********/if(s[i]>='0'_1—s[i]<='9'){n=0;/**********found^*********/while(s[i+l+n]!= 2 )n++;for(j=i+n+l;j>i;j-)/**********f^ound**********/S|J+1]=-3—;s[j+l]='*';i=i+l;})main(){chars[80]="ba3a54cd23a";printf("\nTheoriginalstringis:%s\n",s);fun(s);printf("\nTheresultis:%s\n",s);)二、程序改错题#include<stdio.h>doublefun(intm){doubley=1.0;inti;for(i=2;i<m;i++)]************** nd**************/y+=1/(i*i);retum(y);}main(){intn=5;printf("\nTheresultis%lf\n",fun(n));#include<stdio.h>voidfun(inta[3][3],intb[3][3])main()/・主程序・/{inta[3][3]={{1,2,3},{4,5,6},{7,8,9}},t[3][3];inti,j;voidNONO();fun(a,t);for(i=0;i<3;i++){for(j=0;j<3;j++)printグ%7d”,t「皿);printf('ヽn");}NONO();voidNONO(){/・本函数用于打开文件,输入测试数据,调用fun函数,输出数据,关闭文件。*/intij,k,a[3][3],t[3][3];FILE*rf,*wf;rf=fopen(',K:\\k01\\24010001\\in.dat",Y,);wf=fopen(',K:\\k01\\24010001\\out.dat",nwM);for(k=0;k<5;k++){for(i=0;i<3;i++)fscanf(rf,M%d%d%d”,&a[i][0],&a[i][l],&a[i][2]);fun(a,t);for(i=0;i<3;i++){for(J=0;j<3;j++)fprintf(wf,M%7d';t[i][j]);fprintf(wf,n\nn);))fclose(rf);fclose(wf);第14套题ー、程序填空题#include<stdio.h>voidfun(char*s,int*t){inti,n;n=0;/*******************/for(i=0; 1 !=0;i++)/**********nd**********/if(s[i]>='O'&&s[i]<=_2_)n++;/**********found**********/―3—;)main(){chars[8O]="abcdef35adgh3kjsdf7”;intt;printf(H\nTheoriginalstringis:%s\nu,s);fun(s,&t);primf("\nTheresultis:%d\n”,t);二、程序改错题#include<stdio.h>inifun(int*x,inty)intt;/**************found**************//**************found**************/retum(y);main(){inta=3,b=8;printf(u%d%d\n",a,b);b=fiin(&a,b);printf("%d%d\n”,a,b);}三、程序编写题#include<stdio.h>voidfun(int*a,int*n)main(){intaa[1000],n,k;voidNONO();fun(aa,&n);for(k=0;k<n;k++)if((k+1)%10==0)printf('^\n^^);elseprintf(,,%5d,',aa[k]);NONO();voidNONO(){/・本函数用于打开文件,输入测试数据,调用fun函数,输出数据,关闭文件。*/intaa[1000],n,k;FILE*fp;fp=fopen(',K:\\k01\\24010001\\out.dat'\,,wn);fun(aa,&n);for(k=0;k<n;k++)if((k+1)%10==0)fprintf(fp,”\n");elsefprintf(fp,n%5d",aa[k]);fclose(fp);}第15套题ー、程序填空题#include<stdio.h>voidfun(char*s){inti,n,k;charc;n=0;for(i=0;s[i]!=\0';i++)n++;/**********found**********/if(n%2==0)k=n-_1_;elsek=n-2;/**********found**********/c= 2 ;for(i=k-2;i>=l;i=i-2)s[i+2]=s[i];/********** d**********/S[l]=—3—;main(){chars[80]=nabcdefghM;printf("\nTheoriginalstringis:%s\n",s);fun(s);printf(H\nTheresultis:%s\n0,s);二、程序改错题#include<stdio.h>longfun(inta,intn){intj;/**************found**************/longs=0,t=1;for(j=0;j<n;j++)t=t*10+a;for(j=1;j<n;j++){/**************found**************/t=t%10;}retum(s);main(){inta,n;printf("\nPleaseenteraandn:");scanf("%d%d”,&a,&n);printf("Thevalueoffunctionis:%ld\nM,fun(a,n));)三、程序编写题#include<stdio.h>#include<string.h>voidfun(char*tt,intpp[])main(){charaa[1000);intbb[26],k;voidNONO();printf("\nPleaseenteracharstring:M;scanf(M%sM,aa);fun(aa,bb);for(k=0;kv26;k++)printf(”%dゝbb|k]);printf(Dn“);NONO();voidNONO(){/・本函数用于打开文件,输入测试数据,调用fun函数,输出数据,关闭文件。*/charaa[1000];intbb[26],k,i;FILE*rf,*wf;rf=fopen("K:\\k01\\240100OIWin.daゼ」r”);wf=fopen(',K:\\k01\\24010001\\out.dat",',wH);for(i=0;i<10;i++){fscanf(rf,"%s",aa);fun(aa,bb);for(k=0;k<26;k++)fprintf(wf,n%du,bb[k]);fprintf(wf,"\n");)fclose(rf);fclose(wf);)第16套题ー、程序填空题#include<stdio.h>voidfun(char*s,char*p){inti,j,n,x,t;n=0;for(i=0;s[i]!=W;i++)n++;for(i=l;i<n-2;i=i+2){/**********found**********/ 1 ;/*******************/for(j=_2_+2;j<n;j=j+2)if(s[t]>s[j])t=j;if(t!=i){x=s[i];s[i]=s[t];s[t]=x;}}for(i=lj=0;i<n;i=i+2,j++)p[j]=s[i];/**********found**********/Plj]=__3-;)main(){chars[80]=(,baawrskjghzlicda,',p[50];printf(n\nTheoriginalstringis:%s\n",s);fun(s,p);printf(M\nTheresultis:%s\n'\p);}二、程序改错题#include<math.h>#include<stdio.h>floatfun(floatnum){ints;floatn,t,pi;t=l;pi=0;n=l;s=1;while(t>=num)pi=pi*4;returnpi;)main(){floatnl,n2;printf("Enterafloatnumber:");scanf("%f;&nl);n2=fiin(nl);printf("%6.4An”,n2);三、程序编写题#include<stdio.h>#include<string.h>#defineLEN20voidfiin(chara[],charb[],intn)main(){charstrl[LEN],str2[LEN];intn;voidNONO();printf("EnterthestringAn");gets(strl);printf("Entertheindexofthechardeleted:");scanf("%d",&n);fun(strl,str2,n);printf("Thenewstringis:%s\n",str2);NONO();IvoidNONO(){/・本函数用于打开文件,输入测试数据,调用fun函数,输出数据,关闭文件。*/charstrl[LEN],str2[LEN];inti,n;FILE*rf,*wf;rf=fopen("K:\\k01\\24010001\\in.dat","r");wf=fopen("K:\\kO1W24010001Wout.dat","w");for(i=0;i<10;i++){fscanf(rf,"%s%d'\strl,&n);fun(strl,str2,n);fprintf(wf,"%八n“,str2);)fclose(rf);fclose(wf);第17套题ー、程序填空题#include<stdio.h>voidfiin(char*s,charc){inti,j,n;/*******************/for(i=0;s[i]!= 1 ;i++)if(s[i]==c)/**********tound**********/n= 2 ;while(s[i+l+n]!=W)n++;for(j=i+n+l;j>i;j-)s[j+l]=s|j];/**********found**********/s|j+l]=_3一;i=i+l;})main(){chars[80]="baacda",c;printf(AnThestring:%s\nH,s);printf(H\nInputacharacter:n);scanf("%c",&c);fun(s,c);printf("\nTheresultis:%s\nn,s);二、程序改错题#include<stdio.h>doublefun(intx[])intsum=0.0;intc=0,i=0;while(x[i]!=0){if(x[i]>0){sum+=x[i];C++;}i++;}]************found************/sum\=c;returnsum;)main(){intx[1000];inti=0;printf(n\nPleaseentersomedata(endwith〇):");do{scanf("%d”,&x[i]);}while(x[i++]!=0);printf(,'%f\n,',fun(x));)三、程序编写题#include<stdio.h>doublefun(intn)main(){intn;doubles;voidNONO();printf("\nPleaseenterN:");scanf("%d”,&n);s=fun(n);printf("theresultis:%f\n",s);NONO();)voidNONO(){/・本函数用于打开文件,输入数据,调用函数,输出数据,关闭文
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024-2030年中国孕妇装市场竞争状况及投资趋势分析报告
- 2024-2030年中国多腔高速半自动吹瓶机资金申请报告
- 2024-2030年中国啤酒行业发展规模及前景趋势分析报告
- 2024-2030年中国厢式货车行业市场发展格局及未来投资潜力分析报告
- 2024-2030年中国卸妆产品市场营销模式及发展竞争力分析报告版
- 2024年版摩托车销售合同3篇
- 2024年度环保型砂石生产设备采购合同协议2篇
- 2021-2022学年河南省渑池高级中学高一月考数学试卷
- 2025年哈尔滨货运从业资格证模拟考试0题b2b
- 2025年鹤壁道路货运从业资格证考试
- 海洋平台深水管道高效保温技术
- 《新疆大学版学术期刊目录》(人文社科)
- 充电桩维保投标方案
- 《如何写文献综述》课件
- 肛瘘LIFT术式介绍
- 通过《古文观止》选读了解古代文学的社会功能与价值
- 语言本能:人类语言进化的奥秘
- 职业生涯规划(图文)课件
- 2024版国开电大专科《EXCEL在财务中的应用》在线形考(形考作业一至四)试题及答案
- 能源管理系统平台软件数据库设计说明书
- 中外园林史第七章-中国近现代园林发展
评论
0/150
提交评论