TOP

2012全国计算机二级C语言(C++)题库 第31套题
2011-12-25 00:30:33 来源: 作者: 【 】 浏览:135次 评论:0
微信搜索关注"91考试网"公众号,领30元,获取公务员、事业编、教师等考试资料40G!

31套题

一、程序填空题

#include  <stdio.h>

#define   N   3

#define   M   4

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

void fun(int (*a)[N], int __1__)

{ int i,temp ;

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

  for(i = 0 ; i < __2__ ; i++)

  { temp=a[0][i] ;

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

    a[0][i] = __3__ ;

    a[k][i] = temp ;

  }

}

main()

{ int x[M][N]={ {1,2,3},{4,5,6},{7,8,9},{10,11,12} },i,j;

  printf("The array before moving:\n\n");

  for(i=0; i<M; i++)

  {  for(j=0; j<N; j++) printf("%3d",x[i][j]);

     printf("\n\n");

  }

  fun(x,2);

  printf("The array after moving:\n\n");

  for(i=0; i<M; i++)

  {  for(j=0; j<N; j++) printf("%3d",x[i][j]);

     printf("\n\n");

  }

}

 

 

二、程序改错题

#include <stdio.h>

#include <string.h>

void fun( char t[] )

{

  char c;

  int  i, j;

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

  for( i = strlen( t ); i; i-- )

    for( j = 0; j < i; j++ )

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

      if( t[j] < t[ j + 1 ] )

      {

        c = t[j];

        t[j] = t[ j + 1 ];

        t[j + 1 ] = c;

      }

}

 

main()

{

  char s[81];

  printf( "\nPlease enter a character string: " );

  gets( s );

  printf( "\n\nBefore sorting:\n  \"%s\"", s );

  fun( s );

  printf( "\nAfter sorting decendingly:\n  \"%s\"\n", s );

}

 

 

三、程序编写题

#include <stdio.h>

#include <string.h>

void fun( char *ss )

{

 

 

 

 

}

 

void main( void )

{

   char tt[51];void NONO ();

   printf( "\nPlease enter an character string within 50 characters:\n" );

   gets( tt );

   printf( "\n\nAfter changing, the string\n  \"%s\"", tt );

   fun(tt) ;

   printf( "\nbecomes\n  \"%s\"", tt );

   NONO();

}

 

void NONO ()

{

/* 请在此函数内打开文件,输入测试数据,调用 fun 函数,

   输出数据,关闭文件。 */

   char tt[51], ch;

   FILE *rf, *wf ;

   int len, i=0 ;

 

   rf = fopen("K:\\k01\\24010001\\in.dat","r") ;

   wf = fopen("K:\\k01\\24010001\\out.dat","w") ;

   while(i < 10) {

     fgets( tt, 50, rf );

     len = strlen(tt) - 1 ;

     ch = tt[len] ;

     if(ch == '\n' || ch == 0x1a) tt[len] = 0 ;

     fun(tt);

     fprintf( wf, "%s\n", tt );

     i++ ;

   }

   fclose(rf) ;

   fclose(wf) ;

}

 

Tags: 责任编辑:91kaoshiwang
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇2012全国计算机二级C语言(C++)题.. 下一篇2012全国计算机二级C语言(C++)题..

相关栏目

最新文章

推荐文章

网站客服QQ: 960335752 - 14613519 - 48225117