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

  15、给定程序MODI1.C中函数fun的功能是: 依次取出字符串中所有数字字符, 形成新的字符串, 并取代原字符串。

      请改正函数fun中指定部位的错误, 使它能得出正确的结果。

      注意: 不要改动main函数, 不得增行或删行, 也不得更改程序的结构!

  #include

  void  fun(char  *s)

  {  int  i,j;

     for(i=0,j=0; s[i]!='\0'; i++)

          if(s[i]>='0' && s[i]<='9')

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

              s[j]=s[i];

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

          s[j]="\0";

  }

  main()

  {  char  item[80];

     printf("\nEnter a string  :  ");gets(item);

     printf("\n\nThe  string  is  : \"%s\"\n",item);

     fun(item);

     printf("\n\nThe string of changing is  : \"%s\"\n",item );

  }

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