2017年上半年真题-C语言程序设计.pdfVIP

  • 105
  • 0
  • 约5.04千字
  • 约 6页
  • 2019-01-09 发布于广东
  • 举报
2017年上半年全国高等学校(安徽考区) 计算机水平考试试卷 (二级  C语言程序设计) 一、程序填空题(每题 12 分,共 36 分,将答案填写在相应的下划线处)  1.以下程序从键盘输入一个整数,输出其对应的英文星期单词。若输入的的整数在 1 到 7 之 间外,则输出“Error!”,请填空。  #include stdio.h  void main()  {  int n;  printf(Input n:);  scanf(%d,________);  switch(n)  {  case 1:printf(Monday\n);break;  case 2:printf(Tuesday\n);break;  case 3:printf(Wednessday\n);break;  case 4:printf(Thursday\n);break;  case 5:printf(Friday\n);break;  case 6:printf(Sturday\n);break;  case 7:printf(Sunday\n);_______________;  _________________:printf(Error!\n);  }  }  2.以下程序输出一维数组中的最大元素及其下标值,请填空。  #include stdio.h  int search(int a[],int n)/*求最大元素的下表*/  {  int i,max;  max=________________;  for(i=1;in;i++){  if(a[i]a[max])  max=____________;  }  return max;  }  void main()  {  int a[10]={13,1,­5,4,9,100,­8,7,­6,2};  int max;  ______________=search(a,10); printf(最大值:%d,下标:%d\n,a[max],max);  }  3、以下程序定义求 n!的递归函数 f(),并调用函数 f()求 2!+3!+4!+5!+6!的值,请填空。(说 明:n!=1*2*3*…*n)  #include stdio.h  int f(int n)  {  if(n 1 || n 0)  return ________;  else  return n*f(n­1);  }  void main()  {  int i,s;  s=___________________;  for(i=2;i 6;i++)  s+=f(i);  printf(2!+3!+4!+5!+6!=%d\n,_________________);  }  二、阅读程序题(每题 8 分,共 32 分。将答案填写在相应的空白处)  1、以下程序的运行结果是___________________。  #include stdio.h  void main()  {  int a 3,b=­3,c;  if(ab+3)  c=0;  else  c=­1;  printf(c=%d\n,c);  c=3;  if(ab){  if(3 c)  a=a+b;  else  a=a­b;  }  printf(a=%d,b=%d,c=%d\n,a,b,c);  }  2、以下程序的运行结果是_______________。  #include stdio.h  void main()  { int i,j; 

文档评论(0)

1亿VIP精品文档

相关文档