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

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

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

 填空题
  请补充fun函数,该函数的功能是:分类统计一个字符串中元音字母和其它字符的个数(不区分大小写)。
  例如,输入aeiouAUpqr,记过为A:2 E:1 I:1 O:1 U:2 other:3
  注意:部分源程序给出如下
  请勿改动主函数main和其他函数中的任何内容,仅在fun函数的横线上填入所编写的若干表达式或语句。
  试题程序:
  #include <stdio.h>
  #include <conio.h>
  #define N 100
  void fun(char *str, int bb[])
  {
  char *p = str;
  int i = 0;
  for (i=0; i<6; i++)
  ___1___;
  while (*p)
  {
  switch (*p)
  {
  case 'A':
  case 'a':
  bb[0]++;
  break;
  case 'E':
  case 'e':
  bb[1]++;
  break; 
  case 'I':
  case 'i':
  bb[2]++;
  break;
  case 'O':
  case 'o':
  bb[3]++;
  break;
  case 'U':
  case 'u':
  bb[4]++;
  break;
  default:
  ___2___;
  }
  ___3___
  }
  }
  main()
  {
  char str[N], ss[5] = "AEIOU";
  int i;
  int bb[6];
  printf("Input a string: \n");
  gets(str);
  printf("the string is: \n");
  puts(str);
  fun(str, bb);
  for (i=0; i<5; i++)
  printf("\n%c:%d", ss[i], bb[i]);
  printf("\nother:%d", bb[i]);
  }
  第1处填空:bb[i]=0或*(bb+i)=0
  第2处填空:bb[5]++或++bb[5]或bb[5]=bb[5]+1或bb[5]+=1
  第3处填空:p++;或++p;或p+=1;或p=p+1;


首页 1 2 3 尾页

相关文章