c二级模拟程序题.doc
文本预览下载声明
#include stdio.h
void fibonacci(int f[])
{ int i;
/********fill in the blanks********/
for(i=____;i20;i++)
/********fill in the blanks********/
f[i]=_____;
}
main()
{ int f[20]={1,1},i;
fibonacci(f);
printf(\n菲的前20项:);
for(i=0;i20;i++)
{ if(i%5==0)
printf(\n);
/********fill in the blanks********/
printf(%12d,______);
}
}
菲的前20项:
1 1 2 3 5
8 13 21 34 55
89 144 233 377 610
987 1597 2584 4181 6765Press any key to con
tinue
#include stdio.h
void trans(int a[2][3],int b[3][2])
{ /********Error********/
int i;
for(i=0;i2;i++)
for(j=0;j3;j++)
/********Error********/
a[j][i]=b[i][j];
}
main()
{ int a[2][3]={{1,2,3},{4,5,6}},b[3][2],i,j;
printf(数组a:\n);
for(i=0;i2;i++)
{ for(j=0;j3;j++)
printf(%5d,a[i][j]);
printf(\n);
}
trans(a,b);
printf(数组b:\n);
for(i=0;i3;i++)
{ for(j=0;j2;j++)
printf(%5d,b[i][j]);
printf(\n);
}
}
数组a:
1 2 3
4 5 6
数组b:
1 4
2 5
3 6
Press any key to continue
#include stdio.h
int suffix(int a[],int n)
{
}
main()
{ void CHECK();
int arr[10]={56,178,6,123,87,243,161,124,78,143},k;
k=suffix(arr,10);
printf(数组arr的最大为:arr[%d]=%d\n,k,arr[k]);
}
数组arr的最大为:arr[5]=243
Press any key to continue
#include stdio.h
/********fill in the blanks********/
double sum(int __M__)
{ int i;
double y,d;
/********fill in the blanks********/
y=_____;
for(i=100;i=m;i+=100)
{ d=(double)i*(double)i;
y+=1.0/d;
}
/********fill in the blanks********/
return(___Y___);
}
main()
{ int n=2000;
printf(\nthe result is:%lf\n,sum(n));
}
the result is:0.000160
Press any key to continue
#include stdio.h
/********Error********/
int comp(int x,INT y)
{ int flag;
if(xy)
flag=
显示全部