2011年计算机二级C语言第八十一套上机题库及答案

2014-11-23 22:07:38 · 作者: · 浏览: 34

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


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


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


  给定源程序:


  #include


  #include


  #define N 5


  #define M 8


  int fun(char (*ss)[M],char *t)


  {int i;


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


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


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


  if(strcmp(ss[i],t)==0) return __2__ ;


  return -1;


  }


  main()


  {char ch[N][M]={"if","while","switch","int","for"}, t[M];


  int n,i;


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


  for(i=0;i


  printf("\nEnter a string for search: "); gets(t);


  n=fun(ch,t);


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


  if(n== __3__) printf("\nDon't found!\n");


  else printf("\nThe position is %d .\n",n);


  }


  解题答案:


  /**********第一空**********/


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


  /**********第二空**********/


  if(strcmp(ss[i],t)==0) return i ;


  /**********第三空**********/


  if(n==-1) printf("\nDon't found!\n");


  ******************************************


  相关专题:


  编辑推荐: