2013年计算机二级C语言上机题库十八

考试站(www.examzz.com)   【考试站:中国教育考试第一门户】   2013年4月25日

为方便广大考生更好的复习2013年计算机二级C语言考试,查找考试辅导习题,网校特提供了C语言上机预测题(填空题、改错题、编程题),更多模拟无纸化考试“计算机二级C语言模拟题”,供考生学习。

   填空题
  Str为一个字符序列.请补充FUN函数的功能是:查找STR中值为X 的元素,返回找到值为X的元素个数,并把这些值为X的元素下标依次保存在数组BB中.
  例如,在”abcdefahij”中查找‘A’,结果为:2个‘A’,下标依次为0、6。
  注意:部分源程序给出如下
  请勿改动主函数main和其他函数中的任何内容,仅在横线上填入所编写的若干表达式或语句。
  试题程序:#include <stdio.h>
  #include <conio.h>
  #define N 20
  int bb[N];
  int fun(char *str, char ch)
  {
  int i = 0, n = 0;
  char t = ch;
  char *p = str;
  while (*p)
  {
  if (___1___)
  ___2___;
  p++;
  i++;
  }
  return ___3___;
  }
  main()
  {
  char str[N];
  char ch; 
  int i, n;
  printf("******* Input the original string*******\n ");
  gets(str);
  printf("******* The Original string *******\n");
  puts(str);
  printf("******* Input character *******\n");
  scanf("%c", &ch);
  n = fun(str, ch);
  printf(" \nThe number of character is: %d\n", n);
  printf("******* The suffix of character *******\n");
  for (i=0; i<n; i++)
  printf(" %d ", bb[i]);
  }
  第1处填空:*p==t或t==*p
  第2处填空:bb[n++]=i
  第3处填空:n


首页 1 2 3 尾页

相关文章