全部问题 > 当前问题

嗯。。。。。

include  <stdio.h>

unsigned long fun(unsigned long  n)

{  unsigned long  x=0, s, i;   int  t;

   s=n;

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

   i=1;

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

   while(s>0)  

   {  t=s%10;

      if(t%2==0){

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

         x=x+t*i;  i=i*10;

      }

       s=s/10;

   }

   return  x;

}

main()

{  unsigned long  n=-1;

   while(n>99999999||n<0)

  { printf("Please input(0<n<100000000): ");  scanf("%ld",&n);  }

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

}

这里的循环条件s>0改为s!=0对吗

张欣悦 2017-1-19 21:39:42

共 1 个回答

孤心自留赏孤芳 2017-1-19 22:10:58

应该没问题,因为这里s不能为负,相当于是等效的

问题来自: 填空题真题