当前所在位置:珠峰网资料 >> 计算机 >> 计算机等级考试 >> 正文
2015年计算机二级C语言50套程序填空上机题(23)
发布时间:2011/11/1 9:36:53 来源:城市学习网 编辑:ziteng

  23、给定程序中,函数fun的功能是将a和b所指的两个字符串分别转换成面值相同的整数,并进行相加作为函数值返回,规定字符串中只含9个以下数字字符。

  例如,主函数中输入字符串:32486和12345,在主函数中输出的函数值为:44831。

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

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

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

  #include  

  #include  

  #include  

  #define  N  9

  long  ctod( char  *s )

  { long  d=0;

    while(*s)

      if(isdigit( *s))  {

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

        d=d*10+*s-__1__;

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

        __2__;  }

    return  d;

  }

  long  fun( char  *a, char  *b )

  {

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

    return  __3__;

  }

  main()

  { char  s1[N],s2[N];

    do

    { printf("Input  string  s1 : "); gets(s1); }

    while( strlen(s1)>N );

    do

    { printf("Input  string  s2 : "); gets(s2); }

    while( strlen(s2)>N );

    printf("The result is:  %ld\n", fun(s1,s2) );

  }

广告合作:400-664-0084 全国热线:400-664-0084
Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号
珠峰网 版权所有 All Rights Reserved