二级C语言上机题答案(题库答案)
第一套填空题1.while(p!=NULL)2.if(p->data==ch)returnn;3.k=fun(head,ch);改错1.{intj,c=0;floatxa=0.0;2.if(x[j]>=xa)编程inti=0,j=0;while(a+i
next;3.fun(head,&num);改错1.for(i=j+1;i=eps){sum+=t;i++;t=t*i/(2*i+1);}return2*sum;第三套填空1.s+=p->data;2.p=p->next;3.printf("nsum=%dn",fun(head));改错1.sum=0.0;2.if((i+1)%5==0)编程inti=0,j=0;while(s[i]!=' ')i++;while(t[j]!=' ')j++;if(i>=j)returns;elsereturnt;第四套填空1.STUfun(STU*std,char*num)2.if(strcmp(std[i].num,num)==0)3.return(std[i]);改错1.if(*r==*p){r++;p++;}2.if(*r==' ')编程inti=0,j=0;while(a[i]=='*')i++;if(i>n)for(j=0,i=i-n;a[i];i++)a[j++]=a[i];a[j]=0;第五套填空1.if(std[i].year==year)2.k[n++]=std[i];3.return(n);改错1.aa[i]=m%k;2.for(i=i-1;i>=0;i--)编程inti;floatave=0;for(i=0;iscore[i]*=a;3.modify(&std,a);改错1.for(i=strlen(t)-1;i>=0;i--)2.if(t[j]>t[j+1])编程inti;doubleaver=0;for(i=0;i=ave)b[j++]=a[i];*n=j;returnave;第八套填空1.max=std[0];2.if(max.agen[j])k=j;3.strcpy(ss[k],t);改错1.voidfun(char*a)2.printf("%c",*a);编程*c=b%10*1000+a/10*100+b/10*10+a%10;第十套填空1.n=len;k=i;2.for(j=len;j>=0;j--)3.ss[i][j]='*';改错1.value=FU((a+b),(a-b))+FU((c+b),(c-b));2.return(value);编程STRECc={"",-1};inti;for(i=0;idata=x;2.q=p;3.q->next=s;改错1.intfun(inta[],intm)2.elseif(m>a[mid])编程inti,j=0;for(i=0;i=l&&a[i].s<=h)b[j++]=a[i];returnj;第十二套填空1.nif((fs=fopen(source,"r"))==NULL)2.while(!feof(fs))3.fputc(ch,ft);改错1.switch(g)2.case1:case2:return1;编程STREC*p;doubleave=0;p=h->next;while(p!=NULL){ave+=p->s/N;p=p->next;}returnave;第十三套填空1.fprintf(fp,"%d%fn",i,sqrt((double)i));2.fclose(fp);3.if((fp=fopen(fname,"r"))==NULL)改错1.for(i=0;str[i];i++)2.if(substr[k+1]==' ')编程unsignedn=w;inti=1;while(n>10){i*=10;n/=10;}returnw%i;第十四套填空1.voidWriteText(FILE*fw)2.fputs(str,fw);fputs(""n"",fw);3.printf(""%s"",str);改错1.s[j++]=s[i];2.s[j]=' ';编程inti,max=s[0];*k=0;for(i=1;imax){max=s[i];*k=i;}第十五套填空1.intfun(STYPE*std)2.FILE*fp;inti;3.fwrite(&std[i],sizeof(STYPE),1,fp);改错1.doublek;2.if(*s>*p)编程longt=0;inti=0,flag=1;if(p[i]=='+'){flag=1;i++;}if(p[i]=='-'){flag=-1;i++;}for(;p[i];i++){t=t*10+p[i]-'0';}return(t*flag);第十六套填空1.t=t->next;2.printf(""%d"",t->data);3.free(t);改错1.if(('a'<=tt[i])&&(tt[i]<='z'))2.tt[i]-=32;编程inti;*n=0;for(i=7;i<=m;i++)if(i%7==0||i%11==0)a[(*n)++]=i;第十七套填空1.free(q);2.q=p->next;3.q=q->next;改错1.voidfun(char*s,int*a,int*b)2.*a=1+*a;3.(*b)++;编程inti;*max=a[0];*d=0;for(i=1;i