模拟试题

3773考试网计算机等级考试模拟试题正文

2010年计算机二级C语言上机程序填空题三

来源:fjzsksw.com 2010-9-14 14:19:49

 

 

22、给定程序中,函数fun的功能是:利用指针数组对形参ss所指字符串数组中的字符串按由长到短的顺序排序,并输出排序结果。ss所指字符串数组中共有N个字符串,且串长小于M。

  请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。

  注意:源程序存放在考生文件夹下的BLANK1.C中。

  不得增行或删行,也不得更改程序的结构!

  #include

  #include

  #define N 5

  #define M 8

  void fun(char (*ss)[M])

  { char *ps[N],*tp; int i,j,k;

  for(i=0; i

  for(i=0; i

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

  k= __1__ ;

  for(j=i+1; j

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

  if(strlen(ps[k]) < strlen(__2__) ) k=j;

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

  tp=ps[i]; ps[i]=ps[k]; ps[k]= __3__ ;

  }

  printf("\nThe string after sorting by length:\n\n");

  for(i=0; i

  }

  main()

  { char ch[N][M]={"red","green","blue","yellow","black"};

  int i;

  printf("\nThe original string\n\n");

  for(i=0;i

  fun(ch);

  }

 

 

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] 下一页

触屏版 电脑版
3773考试网 琼ICP备12003406号-1