二级C语言2010年秋季考试(真题汇总)- 副本 联系客服

发布时间 : 星期三 文章二级C语言2010年秋季考试(真题汇总)- 副本更新完毕开始阅读a002116c561252d380eb6ef4

计算机等级考试习题集

四、编程题部分

2.打开程序Cprog242.C,完成其中函数fun(int a[ ],int n),实现将一维数组a各元素在数组中循环右移n个位置。

例如:数组a各元素为:6 7 8 9 0

参数n=2时循环右移2个位置后数组各元素为:9 0 6 7 8

---------- Cprog241.C--------------------------------------------------------------------------------- #include #include #include double fun(double x) { /**/

/**/ }

void main() {

double x;

printf(\ scanf(\

printf(\ getch(); }

---------- Cprog242.C--------------------------------------------------------------------------------- #include #include #define COL 5

void fun(int a[],int n) {

/**/

-17-

计算机等级考试习题集

/**/ }

void main()

{ int arra[COL] = {6,7,8,9,0}; int i,j,n;

printf(\ for(i=0; i

printf(\ scanf(\ fun(arra,n);

printf(\ for(i=0; i

1.打开程序Cprog251.C,完成其中的fun函数,该函数的数学表达式是:

例如:f(2.53)=2.428

2.打开程序Cprog252.C,完成函数fun(int a[ ],int b[ ],float *f),实现如下功能:

1)将数组a中下标为奇数且元素值个位数字为3的所有元素依次存放到数组b中;2)将数组a中下标为偶数的所有元素平均值存放在指针参数f所指向的变量中。

---------- Cprog251.C--------------------------------------------------------------------------------- #include #include #include double fun(double x)

-18-

计算机等级考试习题集

{ /**/

/**/ }

void main() {

printf(\ getch(); }

---------- Cprog252.C--------------------------------------------------------------------------------- #include #include #define N 13

void fun(int a[],int b[],float *f) {

/**/ /**/ }

void main() {

int a[N] = {40,23,33,8,32,63,2,9,16,-3,3,0,13}; int b[N]={0}; int i; float aver; printf(\

-19-

计算机等级考试习题集

for(i=0;i

printf(\ \ printf(\ fun(a,b,&aver); printf(\ i=0;

while(b[i])

printf(\ \ printf(\

printf(\ getch(); }

1.打开程序Cprog261.C,完成其中的fun函数,该函数的数学表达式是:

2.打开程序Cprog262.C,完成函数long fun(int a[ ],int x,int d,int n),实现如下功能:1)以参数x为首项,d为公差,产生等差数列的n项,并依次存于数组a中; 2)函数返回值为所产生等差数列的n项和。

---------- Cprog261.C--------------------------------------------------------------------------------- #include #include #include double fun(float x) {

/**/

/**/ }

void main() { float x;

-20-