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

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

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

 填空题
  请补充函数fun,该函数的功能是:统计所以小于等于n(n>2)的素数的个数,素数的个数作为函数值返回。
  注意:部分源程序给出如下
  请勿改动主函数main和其他函数中的任何内容,仅在fun函数的横线上填入所编写的若干表达式或语句。
  试题程序:
  #include <stdio.h>
  int fun(int n)
  {
  int i, j, count = 0;
  printf("\nThe prime number between 2 to %d\n", n);
  for (i=2; i<=n; i++)
  {
  for (___1___; j<i; j++)
  if (___2___%j == 0)
  break; 
  if (___3___ >= i)
  {
  count++;
  printf(count%15 ? "%5d" : "\n%5d", i);
  }
  }
  return count;
  }
  main()
  {
  int n = 20, r;
  r = fun(n);
  printf("\nThe number of prime is : %d\n", r);
  }
  第1处填空:j=2
  第2处填空:i
  第3处填空:j

 


首页 1 2 3 尾页

相关文章