模拟试题

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

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

来源:fjzsksw.com 2010-9-14 14:48:41

 

 

38、给定程序中,函数fun的功能是:求ss所指字符串数组中长度最短的字符串所在的行下标,作为函数值返回,并把其串长放在形参n所指变量中。ss所指字符串数组****有M个字符串,且串长

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

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

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

  #include

  #include

  #define M 5

  #define N 20

  int fun(char (*ss)[N], int *n)

  { int i, k=0, len= N;

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

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

  { len=strlen(ss[i]);

  if(i==0) *n=len;

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

  if(len ___2___ *n)

  { *n=len;

  k=i;

  }

  }

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

  return(___3___);

  }

  main()

  { char ss[M][N]={"shanghai","guangzhou","beijing","tianjing","chongqing"};

  int n,k,i;

  printf("\nThe original strings are :\n");

  for(i=0;i

  k=fun(ss,&n);

  printf("\nThe length of shortest string is : %d\n",n);

  printf("\nThe shortest string is : %s\n",ss[k]);

  }

 

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

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