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

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

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

  填空题:
  请补充fun函数,该函数的功能是:把一个证书转换成字符串,并到序保存在字符数组str中。例如:当n=12345678时,str=“87654321”。
  请勿改动主函数main和其他函数中的任何内容,仅在fun函数的横线上填入所编写的若干表达式或语句。
  参考答案:
  填空题:
  #include <stdio.h>
  #include <conio.h>
  #define N 80
  char str[N];
  void fun(long int n)
  {
  int i = 0;
  while (___1___)
  {
  str[i] = ___2___;
  n /= 10;
  i++;
  }
  ___3___;
  }
  main()
  {
  long int n = 1234567;
  printf("****** the origial data ********\n");
  printf("n=%ld", n);
  fun(n);
  printf("\n%s", str);
  }
  第一处填空:n>0或0<n
  第二处填空:n%10+’0’或’0’+n%10
  第三处填空:str[i]=’\0’或str[i]=0


首页 1 2 3 尾页

相关文章