计算机二级c语言考试模拟试题,全国计算机二级考试C语言模拟试题(一).doc

1套 每一套题目都是按照“填空题--改错题---编程题”顺序排列

#include

#include

#define N 10

double fun(double *x)

{ int i, j; double av, y[N];

av=0;

/**********found**********/

for(i=0; i

for(i=j=0; i

if( x[i]

/**********found**********/

y[j]=x[i]; x[i]=-1; __j++__;}

i=0;

while(i

{ if( x[i]!= -1 ) y[j++]=x[i];

/**********found**********/

__i++__;

}

for(i=0; i

return av;

}

main()

{ int i; double x[N];

for(i=0; i

printf("\n");

printf("\nThe average is: %f\n",fun(x));

printf("\nThe result :\n",fun(x));

for(i=0; i

printf("\n");

}

改错题

#include

void fun ( char *s, int num[5] )

{ int k, i=5;

for ( k = 0; k

/**********found**********/

num[k]=0;

for (; *s; s++)

{ i = -1;

/**********found**********/

switch (* s )

{ case 'a': case 'A': {i=0; break;}

case 'e': case 'E': {i=1; break;}

case 'i': case 'I': {i=2; break;}

case 'o': case 'O': {i=3; break;}

case 'u': case 'U': {i=4; break;}

}

if (i >= 0)

num[i]++;

}

}

main( )

{ char s1[81]; int num1[5], i;

printf( "\nPlease enter a string: " ); gets( s1 );

fun ( s1, num1 );

for ( i=0; i < 5; i++ ) printf ("%d ",num1[i]); printf ("\n");

}

编程题

#include

#define M 4

#define N 5

int fun ( int a[M][N] )

{

int tot=0,i,j;

for(i=0;i

{

tot+=a[0][i];

tot+=a[M-1][i];

}

for(i=1;i

{

tot+=a[i][0];

tot+=a[i][N-1];

}

return tot;

}

main( )

{ int aa[M][N]={{1,3,5,7,9},

{2,9,9,9,4},

{6,9,9,9,8},

{1,3,5,7,0}};

int i, j, y;void NONO ();

printf ( "The original data is : \n" );

for ( i=0; i

{ for ( j =0; j

printf ("\n");

}

y = fun ( aa );

printf( "\nThe sum: %d\n" , y );

printf("\n");

NO

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值