1 / 32

# 大学C语言改错试题.pdf

rTurboC-------enter10

integers:\n,!); *max=*p;
for(i=0;i&lt;N;i-H-)
4 else
1:/**********F()u if(*p&lt;*min)
 ND**********/min=p;
!get(&quot;%d&quot;,a[i]);&quot;
#\$%/**********F()u&quot;t=*arr;*arr=*min;
 ND**********/-------*/*min=t;
4 m=fun(a,p,N);main()/**********FOU
 (ND**********/
printf(nmax=%d,inta[10];case(max=arr)
position=%dH,mavoidinput();max=min;
X,p))voidoutput();
+)voidmax_min();t=*(arr+n-l);*(arr
*+,-./0input(a,10);+n-l)=*max;*ma
1234&quot;max_min(a,10);x=t;
56-./7&quot;output(a,10);\
f
!89&quot;)voidoutput(int
; &lt;=
,voidinput(int*arr,intn)
1int*arr,intn)(
------------*/fun(int*a,int{int*p,i)int*p,i;
#defineN10*b,intn)p=arr;p=arr;
ND**********/*b=c-a;}enter10changedarray
floatfiin(int*a,int3integers:\nn);is:\n&quot;);
*b,intn)scanf(,,%d,\&amp;a[i]/**********FOu
{);fdr(i=0;i&lt;n;i++)ND**********/
int*c,max=*a;4/**********F()u
max=fun(a,&amp;p,N)ND**********/while(i=0;i&lt;n;i-H-
for(c=a4-l;c&lt;a+n;);
C++)sca(&quot;%d&quot;,&amp;p++);
if(*c&gt;max)FTurboC-------)printf(&quot;%3d&quot;,*p+
{
voidmax_min(int+))
max=*c;&quot;*arr,intn)printf(H\n,!);
/**********FOjj&quot;{)
ND**********/&quot;int; &lt;=
,
b=c-a;}*min,*max,*p,t;1
returnmax;2,&gt;min=max=arr;scanf(H%dn,p-H-);
}?***@102
main())A Bfdr(p=arr+1;p&lt;arrmax=p;
{!CD+n)p++)3
intEFAif(*p&gt;*max)if(max=arr)
a[N],i,max,p=0;!CG/**********F()u4
2inputthelength----------------a-r--r-a-y-:\nH);
for(i=O;n&gt;i;i-H-)ofthearray:\nn);&quot;
2scanf(n%dn,&amp;n);for(i=0;i&lt;N-1;i++
fbr(p=arr;p&lt;arr+nfbr(i=0;i&lt;n;i++))
))4,J
scanf(n%dn,&amp;a[i]KLMN!printf(&quot;%5d&quot;,a[i])
); O@
/**********F()u******@Gprintf(n\nn);
&quot;ND**********/P/**********FOU
&quot;sort(n,a);KLMNND**********/
printf(Houtput
thesorted
4 fbr(i=N-l;i&gt;=0;i+
3,QRSTarray:\nn); )
E10UB
VMfbr(i=0;i&lt;=n-l;i+&quot;ififnumber&lt;=a[i])
 +)&quot;/**********FOU
4 ND**********/
 printf(&quot;%5d&quot;,a[i])*+,-./0a[i]=a[i-l];
91234else
prints&quot;\n&quot;);56-./7
/**********Fou)!89{a[i+l]=number;
ND**********//**********F()u
voidsort(intx,int&quot;&quot;ND**********/
n)------------*/exit;}
{if(number&lt;a[0])
inti,j,k,t;; &lt;=
,a[0]=number;
1void#defineN11printf(HThe
for(i=0;i&lt;n-l;i4-+)sort(int*x,intn)main()resultarray:\nH);
/**********Fou2{
ND**********/for(j=0;j&lt;n-l-i;j+intfor(i=0;i&lt;N;i++)
+)2ij,t,number,a[N]=
for(j=O;j&lt;n-i;j-H-)fdr(j=O;n-l-i&gt;j;j+{1,2,4,6,8,9,12,15printf(&quot;%5d&quot;,a[i])
/**********Fou+)2,149,156);
j++)2enteranintegerto)
if(x[i]&gt;x[i+l])for(j=0;n-(H-i)&gt;j;insertinthe
j++)arrayAn11);f &lt;=
,
{t=x[j];x[j]=x|j+3/**********F()u1
l];x[j+l]=t;}if(xU]&gt;x[j+l])2ND**********/scanf(n%dH,&amp;nu
)if(x[j+l]&lt;x[j])mber);
main()4scanf(,,%d,\&amp;nu2
(sort(a,n);mber)for(i=N-2;i&gt;=0;i+)
inti,n,a[100];printf(nThe2
)tr2[80];=s+l/t;
3pl=strl;1+21+2+3)
a[i+l]=a[i];p2=str2;1+2+3+...+nreturns;
4gets(pl);)
break;}
scanf(n%dn,&amp;m); ! x&quot;
/**********F()uz{V|&quot;
ND**********/!!J}i~1J87Ko
&quot;f &lt;=
,
&quot;strcat(strl[0],str2[#include1
0],m);&lt;&gt;scanf(n%dH,&amp;n);
5,Amain()2float
 Dmputs(pl);puts(p2);(fun(intn)
!)intn;3
&gt;floatfiin();fbr(i=l;i&lt;=n;i++)
; &lt;=
1inputafor(i=l;n&gt;=i;i++)
 {char*pl,*p2;number:&quot;);2
4 2{char/**********Foufor(i=l;i&lt;n+l;i++)
 *p2,*pl;ND**********/2
2pl=scanf(f,%dH,n);fbr(i=l;n+l&gt;i;i++
#include&lt;&gt;strl+m-1;2)
voidstrcopy(charpl=-l+strl+m;printf(&quot;%\n&quot;,4
*str1,char3fun(n));s+=
*str2,intm)while(*pl))s=s+/(float)t;
/**********FOu4/**********F()u2s=s+;2
ND**********/strcopy(strl,str2,ND**********/s+=/(float)t
{charpl,p2;m);fun(intn)
inti,j;(
/**********FOuinii,j,i,
ND**********/
=strl+m;&quot;s=0;&quot;
p2=str2;/**********FOJJ7,\$
/**********F()u6,/\$ND**********/!&#160;z&#161;&#162;Q&#163;
ND**********/!&#160;z&#161;&#164;&#165;\$?&#165;&#166;
if(*pl);&#167;&#168;&#169;,while(i=l;i&lt;=n;i+&#170;&#171;!&#166;&#172;
*p2-H-=*pl++)+);
*p2=&#39;\0&#39;;{*******
}11t=0;*****
main()1***
{S=1+fbr0=l;j&lt;=i;j++)*
inti,m;-----+----------t=t+j;***
char+...+/**********F()u*****
*pl,*p2,strl[801,s&quot;ND**********/*******:.
)&#175;&#176;&#165;,elseif(*p!-
a[i]U]=&#39;*&#39;)?@&quot;ThisisaCk=l;
 ! x)program.&quot;,?elsek=0;
z{V|fbr(i=O;i&lt;N;i++)&gt;&quot;This/**********F()u
!}58{IsACND**********/
&quot;
&quot;for(j=0;j&lt;N;j++))
/**********F()uI
#includeND**********/&quot;main()
&lt;&gt;&quot;{
/**********F()uprintf(&quot;%d&quot;,a[i][j]*+,-./0charstr[81];
ND**********/&#184;)1234clrscr();
main())!89inputaEnglish
{&quot;textline:11);
i
chara[N][N];&quot;gets(str);
inti,j,z;&quot;----------*/printf(&quot;The
clrscr();&quot;originaltextline
fbr(i=O;i&lt;N;i-H-)&quot;is
#includeputs(str);
for(j=0;j&lt;N;j++)f &lt;=
,&lt;&gt;fun(str);
/**********F()u1#includeprintff&#39;Thenew
ND**********/#defineN7&lt;&gt;textlineis:&quot;))
a[i][j]=)2#includeputs(str);
z=0;a[i]Lj]=&#39;&#39;)&lt;&gt;}
3/**********F()u
fbr(i=O;i&lt;(N+1)/2z=z-l;2z-;ND**********/
)i++)2z=-l+z;2fun(charp); &lt;=
,
{z=(n+l)/2-1;2(1
z=(l+n)/2-lintk=0;fun(char*p)2
for(j=z;j&lt;N-z;j++4/**********Foufiin(charp[])
)printf(&quot;%c&quot;,a[i][j]ND**********/2
a[i]U]-*&#39;)&#184;)dowhile(*p!=&#39;\0&#39;)
z=z+l;while(*p==,\0,)2while(*p)
){3
/**********Fouk=l)}
ND**********/&quot;if(k=O&amp;&amp;*p!=&#39;4p++)
z=0;&quot;,)2p=l+p;2
&quot;(++p)2p=p+l)
for(i=(N+l)/2;i&lt;
N;i++)8,?@5*p=toupper(*p);
{z=z-l;&#189;&#190;&#190;&#191;A&#192;/**********F()u&quot;
&#193;&#194;!DND**********/&quot;
fbr(i=z;j&lt;N-z;i++&#195;&#196;k=0;}&quot;:.
?ND**********/
9,A;&#166;&#198;
,01-100
 !&#175;&#199;&#200;&#201;!for(i=l;i&lt;m;i-H-)
&#195;&#202;FB&#175;/**********F()u
&#195;r&#190;&#203;
,oND**********/
&#176;&#165;,?&#199; !4 if(m%i=0)
***@aSdFG?&gt;x&#205;z{|k=0;
asdfgo; &lt;=
,!8/**********F()u
1charND**********/
i
return(*c);2*+,-./0&quot;
#include&lt;&gt;retum(*c);1234&quot;
/**********Fou356-./7&quot;
ND**********/{chars[81],*p=s;!89r&#166;&#198;
:o
chafun(char*c)4&quot;&#199;
(putchar(*p);2&quot;
printf(&quot;%c&quot;,*p);--------*/f&#190;&#203;
,0
i*c&lt;=&#39;Z&#39;&amp;&amp;*c&gt;&#199;
=&#39;A)*c-=&#39;A&#39;-&#39;a&#39;;
/**********F()u\TurboC-----main; &lt;=
,
ND**********/
{1int
returnc;intm,k=0;fiin(intm)2
}fiin(intm)
main()fdr(m=l;m&lt;100;2
/**********F()ur&#207;
m++)for(i=2;i&lt;m;i-H-)
ND**********//*-------------if(fiin(m)==l)2
chars[81],*p=s;(for(i=2;m&gt;i;i++)
gets(s);2
while(*p)&#208; &#209;printf(&quot;%4d&quot;,m);fbr(i=2;i&lt;=m-l;i+
(k++;+)2
*p=fun(p);fbr(i=2;m-l=&gt;i;i+
/**********F()uif(k%5==0)printf(+)
ND**********/&quot;\n&quot;);3
11:\$N&#210;)if(m%i=0)k=0;
printf(&quot;%c&quot;,p);&#211; &#212;)4
p++)fun!&#160;z&#161;,&#213;/**********F()ureturnk;
)&#214;m&#161;&#215;&gt;ND**********/
putchar(&#39;\n&#39;);voidfun(intm)
}&#216;&#161;&#217;&#218;|FTurboC-----
1,&#215;&#220;&#217;&#218;0inti,k=l;
Z&#221;L.&#212;31&#222;XX!nJ&#160;zno&#223;k-0-
&#161;,K&#192;55/**********Fou&quot;:.
&quot;#include&quot;”floatx
;&#207;
fun()s=0,p=l,t=l;2z{V
/*--------------------(float|!}58
&quot;inti=l;p=l,s=0,t=l;2
/**********FOU
&#208; &#209;ND**********/p=l,t=l,s=0;2&quot;
int
&quot;s=0,t=l,p=l;t=l,p=l,s=0;2*+,-./0
+/**********Foufloat1234
ND**********/t=l,s=0,p=l;56-./7
12,&#212;fun3!89
!&#160;z&#161;,Q\$while(fabs(t)&lt;=lewhile(fabs(t)&gt;le-&quot;
!&#224;&#169;&#164;&#225;&#226;-4)4)2&quot;
&#227;!&#228;&#229;&#230;&#231;(while(&lt;fab------------*/
VGs=s+t;s(t))2
&#232;!&#233;E&#230;B&#234;p=-p;while(le-4&lt;fabs(t
&#235;&#234;i=i+2;))2main()
t=p/i)while(fabs(t)&gt;(
&#236;)001)inti;
111/**********F()u4floatt,s=O;
+=1-ND**********/printf(npi=%f\nH,sfloatfac(intn);
&quot;+-----+...*4))/**********F()u
2printf(&quot;pi=%d\n&quot;,ND**********/
357s*4);&#237;TurboC-------
)
fbr(i=l;i&lt;10;i++)
main()&quot;/**********FOu
 ! x(&quot;ND**********/
&#205;z{|!fun();&quot;s=fac(i);
8;&#207;
/*_____________
floatfac(intn)
1
&quot;&quot;&#208; &#209;/**********Fou
*+,-./0;&#166;&#198;
,0&quot;ND**********/
1234&#199;&quot;inty=l;
56-./7&quot;inti;
!89r&#190;&#203;
,o
&quot;&#199;13,\$N&#210;fbr(i=l;i&lt;=n;i+4-)
&quot;&#211; &#212;y=y*i;
------------*/; &lt;=
,fun!&#160;z&#161;,&#164;/**********F()u
11V10!&#238;&#239;!ND**********/
#include&quot;”&#224;&#221;&#212;return;
/**********FOu2float&#224;fUn&#212; )
ND**********/s=0,t=l,p=l;2&#240;
&#241; :.
&quot;ND**********/15,&#212;fun
&quot;14,&#212;fun!&#160;z&#161;,?
&quot;!&#160;z&#161;,&#164;1printfi(,,jiecheng=FabonacciN!
r&#166;&#198;&#242;:0V20!&#238;&#239;!%d\n&quot;,s);&#243;20&#232;,&#244;&#164;&#196;
&#199;&#224;)&#245;&#246;&#211;
main()&#247;&#248;&#249;?
r&#190;&#203;
:0 ! x{&#250;&#251;?
&#199;&#205;z{|!fun();&#252;?&#232;
8)-{&#253;
r &lt;=
:&#234;2&#254;&#234;20o
1&quot;&quot;
fbr(i=l;i&lt;=10;i++)&quot;&quot; !4 ,
2&quot;&quot;x&#205;z{|
for(i=l;10&gt;=i;i++)*+,-./0f&#166;&#198;
,0!8
21234&#199;
for(i=l;i&lt;ll;i++)56-./7&quot;
2!89f&#190;&#203;
,0&quot;
fbr(i=l;ll&gt;i;i++)&quot;&#199;&quot;
2&quot;*+,-./0
s=s+fac(i);2--------*/; &lt;=
,1234
s+=fac(i);1t=l;56-./7
3float2t=;!89
y=;2floatfun()2t=t*j;&quot;
y=i;(2t*=j;&quot;
4intn,j;3-----------*/
returny;2floats=s+t;2s+=t;
return(y);2s=,t=;4
return(y);printfi(,,jiecheng=fiin()
fbr(n=l;n&lt;=20;n+%f\n&quot;,s);{
+)inti;
{;TurboC------float
[TurboC+H+/**********F()u
fl=l,f2=l,f3;

ND**********/&quot;/**********F()u
&quot;s=l;&quot;ND**********/
&quot;&quot;
&quot;for(j=l;j&lt;=n;j++);&#207;
printf(&quot;%8d&quot;,fl);
r&#207;
/**********FOU/*-------------------/**********Fou
/*----------------ND**********/&quot;ND**********/
&quot;t=t*n;&quot;
&quot;/**********F()u&#208; &#209;fbr(i=l;iv=20;i++
&#208; &#209;ND**********/&quot;)
&quot;s+t=s;&quot;(
&quot;)&quot;f3=fl+f2;
/**********Ff)[j/**********FO[J:.
ND**********/fl=f2;--------------------fbr(i=2;i&lt;=m;i++)
f2=fl;4&quot;2
/**********FOjjf2=f3;*+,-./0fbr(i=2;m&gt;=i;i++)
ND**********/12342
f3=f2;56-./7fbr(i=2;i&lt;m+l;i+
ITurboC-------!89+)2
printf(&quot;%&#39;,fl)
&quot;for(i=2;i&lt;l+m;i4-
&quot;&quot;+)2
)------------*/fbr(i=2;m+l&gt;i;i+
printf(&quot;\n&quot;);+)2
};&#207;
for(i=2;l+m&gt;i;i+
main()/*--------------------doublefun(intm)+)
fs2
fun();&quot;doubley=;y-=/(i*i);2
i&#208; &#209;inti;y=y-/(i*i);2
/**********FOJJy-=/(float)(i*i);
&quot;&quot;ND**********/2
&quot;&quot;fbr(i=2;i&lt;m;i+)y=y-/(float)(i*i
/**********Fou))2y=y-;
r&#166;&#198;
,o16,&#212;funND**********/2
&#199;!&#160;z&#161;,&#255;y-=l/(i*i);y=y-/(float)i/(f
m/**********F()uloat)i;
r

oND**********/3
returnm;returny;
)return(y);
r :main()retum(y);
111(
printf(&quot;%&#39;,fl);1intn=5;
t=1-printf(n\ntheFTurboC-------
printf(&quot;%f&#39;,fl);result!
2is%lf\nH,fun(n));
fbr(i=l;i&lt;20;i++))
2x23x3
fbr(i=l;20&gt;i;i++)mxm&quot;#\$%
/*--------------------
fbr(i=2;i&lt;=20;i++)&amp;,(&quot;&quot;
m=5,)*+,
f-.

o&quot;
for(i=2;20&gt;=i;i++)12
/0
for(i=1;i&lt;=19;i++)34#

0&quot;
567,08
for(i=l;19&gt;=i;i++9:
)#
\$ 17
;
fun
31&lt;6=
&gt;?:.
ABCD
fun(&amp;a,&amp;b);E10D6F}
&amp;GaHbprintsHa=%d13/**********FOU
IJ+Kb=%d\nH,a,b);17LND**********/
3H6,+,M}NO
PHkreturn;
a=6b=3QR;
S)
/0&quot;K(kmain()
34D+M500,)(
4567,08&quot;;
M4622o
9:r-.

o/Tprintf(&quot;%d\n&quot;,fun
34(500));
&quot;567,08}
&quot;r
:o9:
&quot;&quot;
UV
WXYZ&quot;&quot;
[\L#
&quot;&quot;
]^WXYT1void&quot;r-.
o
9_fun(int*a,int*b)UV
WXYZ
&quot;fun(int*a,int[\L
&quot;*b)]^WXYTr
:o
-------*/2t=*a;9_
3&quot;
*a=*b;&quot;r1
/**********F()u4-----------*/1
ND**********/*b=t;while
voidfun(inta,b)(&lt;2&lt;=k)&amp;&amp;(mc&lt;l
(intfiin(intk)0))while
intt;{((k&gt;=2)&amp;&amp;(10&lt;
/**********FOUFTurboC------intme))while
ND**********/ m=0,mc=0,j;((2&lt;=k)&amp;&amp;(10&lt;
t=a;&quot;/**********Foume))while
/**********Fou+ND**********/((k&gt;=2)&amp;&amp;(mc&lt;l
ND**********/&quot;while0))while
a=b;r\$% ((k&gt;=2)||(mc&lt;10))((2&lt;=k)&amp;&amp;(mc&lt;
/**********F()u/*-------------------(=9))while
ND**********/+/**********FO(j((k&gt;=2)&amp;&amp;(9&lt;=
b=t;+ND**********/me))while
)12(&lt;2&lt;=k)&amp;&amp;(9&lt;=
&quot;if((k%l3=0)1|(k%me))while
main()+17=0))((k&gt;=2)&amp;&amp;(mc&lt;
+{m=m+k;=9))
inta,b;mc++;}2if
printff&#39;enter\$ 18
;
fun/**********Fou((k%17==0)||(k%
a,b:M);scanf(n%d&lt;6=
ND**********/13==0))
%dn,&amp;a,&amp;b);c+,kYdek++;if!((k%17!=0)&amp;:.
&amp;(k%13!=0))234
3k+;longfun(longnum/=10;567,08
4num)num=num/10;9:
returnm;{3
return(m);/**********FOUscanf(&quot;%ld&quot;,&amp;n);
ND**********/4
[TurboC------longk;printf(&quot;\n%ld\n&quot;,f
 doun(n));UV
WXYZ
{[\L
k*=num%10;]^WXYT
/**********F()ufTurboC------9_
r\$% ND**********/!
num\=10;
}while(num);----------*/
returnk;