模拟试题

3773考试网计算机等级考试模拟试题正文

[组图]2010年计算机二级C语言上机程序填空题二

来源:fjzsksw.com 2010-9-14 14:18:21

 

16、给定程序中,函数fun的功能是:将形参s所指字符串中的数字字符转换成对应的数值,计算出这些数值的累加和作为函数值返回。

  例如,形参s所指的字符串为:abs5def126jkm8,程序执行后的输出结果为:22。

  请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。

  注意:源程序存放在考生文件夹下的BLANK1.C中。

  不得增行或删行,也不得更改程序的结构!

  #include

  #include

  #include

  int fun(char *s)

  { int sum=0;

  while(*s) {

  /**********found**********/

  if( isdigit(*s) ) sum+= *s- __1__ ;

  /**********found**********/

  __2__;

  }

  /**********found**********/

  return __3__ ;

  }

  main()

  { char s[81]; int n;

  printf("\nEnter a string:\n\n"); gets(s);

  n=fun(s);

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

  }

 

 

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]  ... 下一页  >> 

触屏版 电脑版
3773考试网 琼ICP备12003406号-1