我要投稿 投诉建议

3月计算机二级C语言真题及答案(完整版)

时间:2022-12-30 13:33:37 计算机等级 我要投稿
  • 相关推荐

2014年3月计算机二级C语言真题及答案(完整版)

  填空题:

  请补充main()函数,该函数的功能是:从键盘输入一组字符串,以“*”结束输入,并显示出这个字符串。

  例如,输入ABCDEFG*,结果显示ABCDEFG。

  改错题:

  #include

  #include

  void proc(int num,int*b,int*c)

  {

  int i,j,d,y;

  for(i=3;i<=num/2;i=i+2)

  //****found****

  { y=0;

  for(j=2;j<=sqrt((double)i);j++)

  if(i%j==0)y=0;

  if(y==l)

  //****found****

  { d=i-num;

  for(j=2;j<=sqrt((double)d); j++)

  if(d%j==0)y=0;

  if(y==l)

  {*b=i;*c=d;)

  }

  }

  } void main()

  { int mum,b,C;

  do

  { printf("\nlnput num:");

  scanf("%d",&num);)

  while(num%2); ’

  proc(num,&b,&c);

  printf("\n\n%d=%d+%d\n",num,b,c);

  }

  }

  编程题:

  请编写函数proc(),其功能是:将str所指字符串中除下标为偶数,同时ASCII码值为奇数的字符外,其余的字符都删除,串中剩余字符所 形成的一个新串放在t所指的数组中。例如,若str所指字符串中的内容为ABCDEFG12345,其中字符8的ASCII码值为偶数,所在元素的下标为 奇数,因此必须删除;而字符A的ASCII码值为奇数,所在数组中的下标为偶数,因此不应当删除。依此类推,最后t所指的数组中的内容应是 ACEG。

  注意:部分源程序给出如下。

  请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的花括号中填入所写的若干语句。

  试题程序:

  #include

  #include

  #include

  #include

  void proc(char*str,char t[])

  {

  }

  void main()

  {

  char str[100],t[100];

  system("CLS"):

  printf("\nPlease enter string str:");

  scanf("%s",str);

  proc(str,t);

  printf("\nThe result is:%s\n",t);

  }

 

http://www.cnrencai.com/

【3月计算机二级C语言真题及答案(完整版)】相关文章:

计算机二级c语言考试习题及答案07-29

2014年计算机二级C语言模拟试题及答案(3)08-04

职称英语综合C试题真题(含答案)07-25

计算机二级c语言试题07-15

2017年9月计算机二级C++考试强化模拟试题及答案07-29

2014年计算机二级C语言模拟试题及答案(1)08-04

2014年计算机二级C语言模拟试题及答案(2)08-04

2017计算机二级C语言试题09-25

2017年9月计算机二级考试C语言预测试题07-29

计算机二级C++考试知识巩固题07-28