就业数据资源平台
当前位置:首页 > Visual FoxPro
2013年计算机二级考试VFP上机精选题及答案14

补充fun函数,该函数的功能是:返回字符数组中指定字符的个数,指定字符从键盘输入。
  请勿改动主函数main和其他函数中的任何内容,仅在fun函数的横线上填入所编写的若干#include <stdio.h>
  #define N 80
  int fun(char s[], char ch)
  {
  int i = 0, n = 0;
  while (___1___)
  {
  if (___2___)
  n++;
  i++;
  }
  ___3___;
  }
  main()
  {
  int n;
  char str[N], ch;
  printf("\nInput a string:\n");
  gets(str);
  printf("\nInput a character:\n");
  scanf("%c", &ch);
  n=fun(str, ch);
  printf("\nnumber of %c: %d", ch, n);
  }表达式或语句。
  参考答案:
  1、s[i]或s[i]!=0
  2、s[i]==ch或ch==s[i]
  3、return n
就业数据资源平台