填空真题第一题
小迷糊 核心会员 2015-09-04 14:33:25
1909 1 0
问题来自: 填空题真题

共 1 个回答

    浅↑夏忆↓瞬 人气红星 3595天前

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

    填空1:变量i用来控制被取出的偶数在新数中的位置,应赋初值1。
    填空2:while语句的循环条件是s>0。
    填空3:变量i用来标识个位、百位和千位等。

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

  • 0

    点赞

  • 扫一扫分享朋友圈

    二维码

  • 分享

相关问题