X是怎么加起来的,没有将所有X加起来的语句啊!
凉撤. 高级粉丝 2018-08-24 12:14:15
1613 2 0

#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));

}


问题来自: 填空题真题

共 2 个回答

    凉撤. 高级粉丝 2510天前

    x=x+t*i

    【C语言】桦桦 人气新星 2510天前

       while(s>0)

       {  t=s%10;

          if(t%2==0){

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

             x=x+t*i;  i=i*10;[]如果t是2的倍数,那么,x=x+ti,之后i变为原来的10倍

          }

     s=s/10;  s缩小10倍取整数

       }进入下次循环


您还没有登录,所以不能回复该问题
我要回复

  • 0

    点赞

  • 扫一扫分享朋友圈

    二维码

  • 分享

相关问题