1 / 32
文档名称:

大学C语言改错试题.pdf

格式:pdf   大小:6,122KB   页数:32页
下载后只包含 1 个 PDF 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

大学C语言改错试题.pdf

上传人:fangjinyan2017001 9/23/2022 文件大小:5.98 MB

下载得到文件列表

大学C语言改错试题.pdf

相关文档

文档介绍

文档介绍:该【大学C语言改错试题 】是由【fangjinyan2017001】上传分享,文档一共【32】页,该文档可以免费在线阅读,需要了解更多关于【大学C语言改错试题 】的内容,可以使用淘豆网的站内搜索功能,选择自己适合的文档,以下文字是截取该文章内的部分文字,如需要获得完整电子版,请下载此文档到您的设备,方便您编辑和打印。:.
rTurboC-------enter10

integers:\n,!); *max=*p;
for(i=0;i<N;i-H-)
4 else
1:/**********F()u if(*p<*min)
 ND**********/min=p;
 !get("%d",a[i]);"
#$%/**********F()u"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"max_min(a,10);x=t;
56-./7"output(a,10);\
f
!89")voidoutput(int
; <=
,voidinput(int*arr,intn)
1int*arr,intn)(
------------*/fun(int*a,int{int*p,i)int*p,i;
#defineN10*b,intn)p=arr;p=arr;
/**********Fou2printf(^pleaseprintf("The
ND**********/*b=c-a;}enter10changedarray
floatfiin(int*a,int3integers:\nn);is:\n");
*b,intn)scanf(,,%d,\&a[i]/**********FOu
{);fdr(i=0;i<n;i++)ND**********/
int*c,max=*a;4/**********F()u
max=fun(a,&p,N)ND**********/while(i=0;i<n;i-H-
for(c=a4-l;c<a+n;);
C++)sca("%d",&p++);
if(*c>max)FTurboC-------)printf("%3d",*p+
{
voidmax_min(int+))
max=*c;"*arr,intn)printf(H\n,!);
/**********FOjj"{)
ND**********/"int; <=
,
b=c-a;}*min,*max,*p,t;1
returnmax;2,>min=max=arr;scanf(H%dn,p-H-);
}?***@102
main())A Bfdr(p=arr+1;p<arrmax=p;
{!CD+n)p++)3
intEFAif(*p>*max)if(max=arr)
a[N],i,max,p=0;!CG/**********F()u4
printf(npleaseEF)?ND**********/fbr(i=0;ivn;i++):.
2inputthelength----------------a-r--r-a-y-:\nH);
for(i=O;n>i;i-H-)ofthearray:\nn);"
2scanf(n%dn,&n);for(i=0;i<N-1;i++
fbr(p=arr;p<arr+nfbr(i=0;i<n;i++))
))4,J
scanf(n%dn,&a[i]KLMN!printf("%5d",a[i])
); O@
/**********F()u******@Gprintf(n\nn);
"ND**********/P/**********FOU
"sort(n,a);KLMNND**********/
printf(Houtput
thesorted
4 fbr(i=N-l;i>=0;i+
3,QRSTarray:\nn); )
E10UB
VMfbr(i=0;i<=n-l;i+"ififnumber<=a[i])
 +)"/**********FOU
4 ND**********/
 printf("%5d",a[i])*+,-./0a[i]=a[i-l];
91234else
prints"\n");56-./7
/**********Fou)!89{a[i+l]=number;
ND**********//**********F()u
voidsort(intx,int""ND**********/
n)------------*/exit;}
{if(number<a[0])
inti,j,k,t;; <=
,a[0]=number;
1void#defineN11printf(HThe
for(i=0;i<n-l;i4-+)sort(int*x,intn)main()resultarray:\nH);
/**********Fou2{
ND**********/for(j=0;j<n-l-i;j+intfor(i=0;i<N;i++)
+)2ij,t,number,a[N]=
for(j=O;j<n-i;j-H-)fdr(j=O;n-l-i>j;j+{1,2,4,6,8,9,12,15printf("%5d",a[i])
/**********Fou+)2,149,156);
ND**********/for(j=0;j<n-(l+i);printfif^pleaseprintf("\n");
j++)2enteranintegerto)
if(x[i]>x[i+l])for(j=0;n-(H-i)>j;insertinthe
j++)arrayAn11);f <=
,
{t=x[j];x[j]=x|j+3/**********F()u1
l];x[j+l]=t;}if(xU]>x[j+l])2ND**********/scanf(n%dH,&nu
)if(x[j+l]<x[j])mber);
main()4scanf(,,%d,\&nu2
(sort(a,n);mber)for(i=N-2;i>=0;i+)
inti,n,a[100];printf(nThe2
printf(npleaseoriginalfor(i=N-2;0<=i;i+:.
)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,&m); ! x"
/**********F()uz{V|"
ND**********/!!J}i~1J87€Ko
"f <=
,
"strcat(strl[0],str2[#include1
0],m);<>scanf(n%dH,&n);
5,Aˆmain()2float
‰Š Dmˆputs(pl);puts(p2);(fun(intn)
‰‹Œ!Žˆ)intn;3
‰‘>’floatfiin();fbr(i=l;i<=n;i++)
ˆ‰; <=
,printffPlease2
Š1inputafor(i=l;n>=i;i++)
 {char*pl,*p2;number:");2
4 2{char/**********Foufor(i=l;i<n+l;i++)
 *p2,*pl;ND**********/2
2pl=scanf(f,%dH,n);fbr(i=l;n+l>i;i++
#include<>strl+m-1;2)
voidstrcopy(charpl=-l+strl+m;printf("%\n",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;"s=0;"
p2=str2;/**********FOJJ7,$Ÿ
/**********F()u6,/$ND**********/! z¡¢Q£
ND**********/! z¡¤¥$?¥¦
if(*pl);§¨©,while(i=l;i<=n;i+ª«!¦¬
*p2-H-=*pl++)+);
*p2='\0';{*******
}11t=0;*****
main()1***
{S=1+fbr0=l;j<=i;j++)*
inti,m;-----+----------t=t+j;***
char+...+/**********F()u*****
*pl,*p2,strl[801,s"ND**********/*******:.
)¯°¥,elseif(*p!-
a[i]U]='*')?@"ThisisaCk=l;
 ! x)program.",?elsek=0;
z{V|fbr(i=O;i<N;i++)>"This/**********F()u
!}58€{IsACND**********/
"
"for(j=0;j<N;j++))
/**********F()uI
#includeND**********/"main()
<>"{
/**********F()uprintf("%d",a[i][j]*+,-./0charstr[81];
ND**********/¸)1234clrscr();
#defineN=7printfif,l\nn);56-./7printf(,,please
main())!89inputaEnglish
{"textline:11);
i
chara[N][N];"gets(str);
inti,j,z;"----------*/printf("The
clrscr();"originaltextline
fbr(i=O;i<N;i-H-)"is
#includeputs(str);
for(j=0;j<N;j++)f <=
,<>fun(str);
/**********F()u1#includeprintff'Thenew
ND**********/#defineN7<>textlineis:"))
a[i][j]=)2#includeputs(str);
z=0;a[i]Lj]='')<>}
3/**********F()u
fbr(i=O;i<(N+1)/2z=z-l;2z-;ND**********/
)i++)2z=-l+z;2fun(charp); <=
,
{z=(n+l)/2-1;2(1
z=(l+n)/2-lintk=0;fun(char*p)2
for(j=z;j<N-z;j++4/**********Foufiin(charp[])
)printf("%c",a[i][j]ND**********/2
a[i]U]-*')¸)dowhile(*p!='\0')
z=z+l;while(*p==,\0,)2while(*p)
){3
/**********Fouk=l)}
ND**********/"if(k=O&&*p!='4p++)
z=0;",)2p=l+p;2
"(++p)2p=p+l)
for(i=(N+l)/2;i<
N;i++)8,?@5*p=toupper(*p);
{z=z-l;½¾¾¿AÀ/**********F()u"
ÁÂ!DND**********/"
fbr(i=z;j<N-z;i++ˆÃđk=0;}":.
?ND**********/
9,Aˆ;¦Æ
,01-100
‰Š !¯ˆÇÈÉ!Žfor(i=l;i<m;i-H-)
ÃÊF‘B¯ˆ/**********F()u
Ãr¾Ë
,oND**********/
°¥,?Ç !4 if(m%i=0)
***@aSdFG?>xÍz{|k=0;
asdfgo; <=
,!8€/**********F()u
1charND**********/
i
return(*c);2*+,-./0"
#include<>retum(*c);1234"
/**********Fou356-./7"
ND**********/{chars[81],*p=s;!89r¦Æ
:o
chafun(char*c)4"Ç
(putchar(*p);2"
printf("%c",*p);--------*/f¾Ë
,0
i*c<='Z'&&*c>Ç
='A)*c-='A'-'a';
/**********F()u\TurboC-----main; <=
,
ND**********/
{1int
returnc;intm,k=0;fiin(intm)2
}fiin(intm)
main()fdr(m=l;m<100;2
/**********F()urÏ
m++)for(i=2;i<m;i-H-)
ND**********//*-------------if(fiin(m)==l)2
chars[81],*p=s;(for(i=2;m>i;i++)
gets(s);2
while(*p)Ð Ñprintf("%4d",m);fbr(i=2;i<=m-l;i+
(k++;+)2
*p=fun(p);fbr(i=2;m-l=>i;i+
/**********F()uif(k%5==0)printf(+)
ND**********/"\n");3
11:$NÒ)if(m%i=0)k=0;
printf("%c",p);Ó Ô)4
p++)fun! z¡,Õ/**********F()ureturnk;
)Öm¡×>ND**********/
putchar('\n');voidfun(intm)
}Ø¡ÙÚ|FTurboC-----
1,×ÜÙÚ0inti,k=l;
ZÝL.Ô31ÞXX!nJ znoßk-0-
¡,KÀ55/**********Fou":.
"#include"”floatx
;Ï
fun()s=0,p=l,t=l;2z{V
/*--------------------(float|!}58€
"inti=l;p=l,s=0,t=l;2
/**********FOU
Ð ÑND**********/p=l,t=l,s=0;2"
int
"s=0,t=l,p=l;t=l,p=l,s=0;2*+,-./0
+/**********Foufloat1234
ND**********/t=l,s=0,p=l;56-./7
12,Ôfun3!89
! z¡,Q$while(fabs(t)<=lewhile(fabs(t)>le-"
Ÿ!੤áâ-4)4)2"
ã!äåæç(while(<fab------------*/
VGs=s+t;s(t))2
è!éEæBêp=-p;while(le-4<fabs(t
ëêi=i+2;))2main()
t=p/i)while(fabs(t)>(
ì)001)inti;
111/**********F()u4floatt,s=O;
+=1-ND**********/printf(npi=%f\nH,sfloatfac(intn);
"+-----+...*4))/**********F()u
2printf("pi=%d\n",ND**********/
357s*4);íTurboC-------
)
fbr(i=l;i<10;i++)
main()"/**********FOu
 ! x("ND**********/
Íz{|!fun();"s=fac(i);
8€;Ï
/*_____________
floatfac(intn)
1
""Ð Ñ/**********Fou
*+,-./0;¦Æ
,0"ND**********/
1234Ç"inty=l;
56-./7"inti;
!89r¾Ë
,o
"Ç13,$NÒfbr(i=l;i<=n;i+4-)
"Ó Ôy=y*i;
------------*/; <=
,fun! z¡,¤/**********F()u
11V10!îï!ND**********/
#include"”àÝÔreturn;
/**********FOu2floatàfUnÔ )
ND**********/s=0,t=l,p=l;2ð
ñ :.
"ND**********/15,Ôfun
"14,Ôfun! z¡,?
"! z¡,¤1printfi(,,jiecheng=FabonacciN!
r¦Æò:0V20!îï!%d\n",s);ó20è,ô¤Ä
Çà)õöÓ
main()÷‘øù?
r¾Ë
:0 ! x{úû?
ÇÍz{|!fun();Žü?è
8€)-{ý
r <=
:ê2þê20o
1""
fbr(i=l;i<=10;i++)"" !4 ,
2""xÍz{|
for(i=l;10>=i;i++)*+,-./0f¦Æ
,0!8€
21234Ç
for(i=l;i<ll;i++)56-./7"
2!89f¾Ë
,0"
fbr(i=l;ll>i;i++)"Ç"
2"*+,-./0
s=s+fac(i);2--------*/; <=
,1234
s+=fac(i);1t=l;56-./7
3float2t=;!89
y=;2floatfun()2t=t*j;"
y=i;(2t*=j;"
4intn,j;3-----------*/
returny;2floats=s+t;2s+=t;
return(y);2s=,t=;4
return(y);printfi(,,jiecheng=fiin()
fbr(n=l;n<=20;n+%f\n",s);{
+)inti;
{;TurboC------float
[TurboC+H+/**********F()u
fl=l,f2=l,f3;

ND**********/"/**********F()u
"s=l;"ND**********/
""
"for(j=l;j<=n;j++);Ï
printf("%8d",fl);
rÏ
/**********FOU/*-------------------/**********Fou
/*----------------ND**********/"ND**********/
"t=t*n;"
"/**********F()uÐ Ñfbr(i=l;iv=20;i++
Ð ÑND**********/")
"s+t=s;"(
")"f3=fl+f2;
/**********Ff)[j/**********FO[J:.
ND**********/fl=f2;--------------------fbr(i=2;i<=m;i++)
f2=fl;4"2
/**********FOjjf2=f3;*+,-./0fbr(i=2;m>=i;i++)
ND**********/12342
f3=f2;56-./7fbr(i=2;i<m+l;i+
ITurboC-------!89+)2
printf("%',fl)
"for(i=2;i<l+m;i4-
""+)2
)------------*/fbr(i=2;m+l>i;i+
printf("\n");+)2
};Ï
for(i=2;l+m>i;i+
main()/*--------------------doublefun(intm)+)
fs2
fun();"doubley=;y-=/(i*i);2
iÐ Ñinti;y=y-/(i*i);2
/**********FOJJy-=/(float)(i*i);
""ND**********/2
""fbr(i=2;i<m;i+)y=y-/(float)(i*i
/**********Fou))2y=y-;
r¦Æ
,o16,ÔfunND**********/2
Ç! z¡,ÿy-=l/(i*i);y=y-/(float)i/(f
m/**********F()uloat)i;
r

oND**********/3
returnm;returny;
)return(y);
r :main()retum(y);
111(
printf("%',fl);1intn=5;
t=1-printf(n\ntheFTurboC-------
printf("%f',fl);result!
2is%lf\nH,fun(n));
fbr(i=l;i<20;i++))
2x23x3
fbr(i=l;20>i;i++)mxm"#$%
/*--------------------
fbr(i=2;i<=20;i++)&,(""
m=5,)*+,
f-.

o"
for(i=2;20>=i;i++)12
/0
for(i=1;i<=19;i++)34#

0"
567,08
for(i=l;19>=i;i++9:
)#
$ 17
;
fun
31<6=
>?:.
ABCD
fun(&a,&b);E10D6F}
&GaHbprintsHa=%d13/**********FOU
IJ+Kb=%d\nH,a,b);17LND**********/
3H6,+,M}NO
PHkreturn;
a=6b=3QR;
S)
/0"K(kmain()
34D+M500,)(
4567,08";
M4622o
9:r-.

o/Tprintf("%d\n",fun
34(500));
"567,08}
"r
:o9:
""
UV
WXYZ""
[\L#
""
]^WXYT1void"r-.
o
9_fun(int*a,int*b)UV
WXYZ
"fun(int*a,int[\L
"*b)]^WXYTr
:o
-------*/2t=*a;9_
3"
*a=*b;"r1
/**********F()u4-----------*/1
ND**********/*b=t;while
voidfun(inta,b)(<2<=k)&&(mc<l
(intfiin(intk)0))while
intt;{((k>=2)&&(10<
/**********FOUFTurboC------intme))while
ND**********/ m=0,mc=0,j;((2<=k)&&(10<
t=a;"/**********Foume))while
/**********Fou+ND**********/((k>=2)&&(mc<l
ND**********/"while0))while
a=b;r$% ((k>=2)||(mc<10))((2<=k)&&(mc<
/**********F()u/*-------------------(=9))while
ND**********/+/**********FO(j((k>=2)&&(9<=
b=t;+ND**********/me))while
)12(<2<=k)&&(9<=
"if((k%l3=0)1|(k%me))while
main()+17=0))((k>=2)&&(mc<
+{m=m+k;=9))
inta,b;mc++;}2if
printff'enter$ 18
;
fun/**********Fou((k%17==0)||(k%
a,b:M);scanf(n%d<6=
ND**********/13==0))
%dn,&a,&b);c+,kYdek++;if!((k%17!=0)&:.
&(k%13!=0))234
3k+;longfun(longnum/=10;567,08
4num)num=num/10;9:
returnm;{3
return(m);/**********FOUscanf("%ld",&n);
ND**********/4
[TurboC------longk;printf("\n%ld\n",f
 doun(n));UV
WXYZ
{[\L
k*=num%10;]^WXYT
/**********F()ufTurboC------9_
r$% ND**********/!
num\=10;
}while(num);----------*/
returnk;