我国计算机的二级C语言上机题库 50套填空与改错Word文档下载推荐.docx
《我国计算机的二级C语言上机题库 50套填空与改错Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《我国计算机的二级C语言上机题库 50套填空与改错Word文档下载推荐.docx(112页珍藏版)》请在冰点文库上搜索。
*p=t;
t=t%1000;
returnt;
{longt,r;
intx,y;
\nInputxandy:
"
scanf("
%ld%ld"
&
x,&
y);
t=fun(x,y,&
r);
\n\nx=%d,y=%d,r=%ld,last=%ld\n\n"
x,y,r,t);
1程序填空题
intc1,c2,c3;
voidfun(longn)
{c1=c2=c3=0;
while(n){
switch(n%10)
{
case1:
c1++;
break;
case2:
c2++;
case3:
c3++;
n/=10;
{longn=123114350L;
fun(n);
\nTheresult:
n=%ldc1=%dc2=%dc3=%d\n"
n,c1,c2,c3);
intfun(unsignedn,int*zero)
{intcount=0,max=0,t;
do
{t=n%10;
if(t==0)
count++;
if(max<
t)max=t;
n=n/10;
}while(n);
*zero=count;
returnmax;
{unsignedn;
intzero,max;
\nInputn(unsigned):
%d"
n);
max=fun(n,&
zero);
\nTheresult:
max=%dzero=%d\n"
max,zero);
unsignedlongfun(unsignedlongn)
{unsignedlongx=0;
intt;
while(n)
if(t%2==0)
x=10*x+t;
returnx;
{unsignedlongn=-1;
while(n>
99999999||n<
0)
{printf("
Pleaseinput(0<
n<
100000000):
%ld"
\nTheresultis:
%ld\n"
fun(n));
voidfun(longs,long*t)
{intd;
longsl=1;
/************found************/
*t=0;
while(s>
0)
{d=s%10;
if(d%2!
=0)
{*t=d*sl+*t;
sl*=10;
s/=10;
{longs,t;
\nPleaseenters:
"
&
s);
fun(s,&
t);
Theresultis:
t);
第4套校园网·
新视野教育上机考试复习资料
#defineM3
#defineN4
voidfun(int(*a)[N])
{inti=0,j,find=0,rmax,c,k;
while((i<
M)&
&
(!
find))
{rmax=a[i][0];
c=0;
for(j=1;
j<
N;
j++)
if(rmax<
a[i][j]){
rmax=a[i][j];
c=j;
}
find=1;
k=0;
while(k<
M&
find){
if(k!
=i&
a[k][c]<
=rmax)find=0;
k++;
if(find)printf("
find:
a[%d][%d]=%d\n"
i,c,a[i][c]);
i++;
if(!
find)printf("
notfound!
{intx[M][N],i,j;
Enternumberforarray:
for(i=0;
M;
for(j=0;
j++)scanf("
x[i][j]);
Thearray:
{for(j=0;
j++)printf("
%3d"
x[i][j]);
\n\n"
fun(x);
doublefun(intm)
{doubley=1.0;
inti;
for(i=2;
i<
=m;
i++)
y-=1.0/i/i;
return(y);
main()
{intn=5;
printf("
\nTheresultis%lf\n"
fun(n));
string.h>
#defineN5
#defineM10
voidfun(char(*ss)[M],intk)
{inti=0;
while(i<
N){
ss[i][k]=0;
i++;
{charx[N][M]={"
Create"
"
Modify"
Sort"
skip"
Delete"
};
inti;
\nTheoriginalstring\n\n"
i<
i++)puts(x[i]);
fun(x,4);
\nThestringafterdeleted:
i++)puts(x[i]);
doublefun(doubleeps)
{doubles,t;
intn=1;
s=0.0;
t=1;
while(t>
eps)
{s+=t;
t=t*n/(2*n+1);
return(2*s);
{doublex;
\nPleaseenteraprecision:
%lf"
x);
\neps=%lf,Pi=%lf\n\n"
x,fun(x));
第6套校园网·
voidfun(int(*t)[N])
{inti,j;
i;
t[i][j]=t[i][j]+t[j][i];
t[j][i]=0;
{intt[][N]={21,12,13,24,25,16,47,38,29,11,32,54,42,21,33,10},i,j;
\nTheoriginalarray:
%2d"
t[i][j]);
fun(t);
stdlib.h>
#defineFU(m,n)((m)/(n))
floatfun(floata,floatb,floatc)
{floatvalue;
value=FU(a+b,a-b)+FU(c+b,c-b);
Return(value);
{floatx,y,z,sum;
Inputxyz:
%f%f%f"
y,&
z);
x=%f,y=%f,z=%f\n"
x,y,z);
if(x==y||y==z){printf("
Dataerror!
exit(0);
sum=fun(x,y,z);
Theresultis:
%5.2f\n"
sum);
}
第7套校园网·
#defineN3
#defineM4
voidfun(int(*a)[N],intk)
{inti,temp;
for(i=0;
n;
{temp=a[0][i];
a[0][i]=a[k][i];
a[k][i]=temp;
{intx[M][N]={{1,2,3},{4,5,6},{7,8,9},{10,11,12}},i,j;
Thearraybeforemoving:
fun(x,2);
Thearrayaftermoving:
voidfun(chart[])
{
charc;
inti,j;
/**********found***********/
for(i=strlen(t)-1;
i;
i--)
for(j=0;
j<
j++)
if(t[j]>
t[j+1])
c=t[j];
t[j]=t[j+1];
t[j+1]=c;
chars[81];
\nPleaseenteracharacterstring:
);
gets(s);
\n\nBeforesorting:
\n\"
%s\"
s);
fun(s);
\nAftersortingdecendingly:
intfun(intx)
{intn,s1,s2,s3,t;
n=0;
t=100;
while(t<
=999){
s1=t%10;
s2=(t/10)%10;
s3=t/100;
if(s1+s2+s3==x)
%d"
t);
t++;
returnn;
{intx=-1;
while(x<
Pleaseinput(x>
0):
%d\n"
fun(x));
{longsl=10;
*t=s%10;
{s=s/100;
*t=s%10*sl+*t;
sl=sl*10;
fun(intt[][N],intn)
{inti,sum;
sum=0;
n;
sum+=t[i][i];
sum+=t[i][n-i-1];
returnsum;
{intt[][N]={21,2,13,24,25,16,47,38,29,11,32,54,42,21,3,10},i,j;
\nTheoriginaldata:
%4d"
%d"
fun(t,N));
doublefunx(doublex)
{return(2*x*x*x-4*x*x+3*x-6);
doublefun(doublem,doublen)
doubler;
r=(m+n)/2;
while(fabs(n-m)>
0.001)
{if(funx(r)*funx(n)<
0)m=r;
elsen=r;
returnr;
{doublem,n,root;
Entermn:
\n"
%lf%lf"
m,&
root=fun(m,n);
root=%6.3f\n"
root);
charfun(charch)
if(ch>
='
0'
&
ch<
9'
)
return'
-(ch-'
returnch;
{charc1,c2;
c1='
2'
;
c2=fun(c1);
c1=%cc2=%c\n"
c1,c2);
8'
a'
voidfun(char*p,char*b)
{inti,k=0;
while(*p)
{i=1;
while(i<
=3&
*p){
b[k]=*p;
p++;
删除?
if(*p)
b[k]='
'
k++;
\0'
{chara[80],b[80];
Enterastring:
gets(a);
Theoriginalstring:
puts(a);
fun(a,b);
\nThestringafterinsertspace:
puts(b);
doublefun(doublee)
doubles,x;
s=0;
i=0;
2
x=1.0;
while(x>
e){
x=(2.0*i-1)/((2.0*i)*(2.0*i));
s=s+x;
returns;
{doublee=1e-3;
\nT