计算机二级

3773考试网计算机等级考试计算机二级正文

2014年3月全国计算机二级C语言上机模拟试题八十九1

来源:2exam.com 2013-12-31 13:26:58

给定程序中,函数fun的功能是:求出形参ss所指字符串数组中最长字符串的 长度,其余字符串左边用字符*补齐,使其与最长的字符串等长。字符串数组中共 有M个字符串,且串长  请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 

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

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

  给定源程序: 

  #include  

  #include  

  #define M 5 

  #define N 20 

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

  { int i, j, k=0, n, m, len; 

  for(i=0; i  { len=strlen(ss[i]); 

  if(i==0) n=len; 

  if(len>n) { 

  n=len; ___1___=i; 

  } 

  } 

  for(i=0; i  if (i!=k) 

  { m=n; 

  len=strlen(ss[i]); 

  for(j=___2___; j>=0; j--) 

  ss[i][m--]=ss[i][j]; 

  for(j=0; j  ___3___=’*’; 

  } 

  } 

  main() 

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

  int i; 

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

  for(i=0; i  printf("\n"); 

  fun(ss); 

  printf("\nThe result:\n"); 

  for(i=0; i  }

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