编写函数long compose(long number)完成如下功能:将长整型数中数字为偶数的数依次取出,构成一个新数返回。
#include<stdio.h>
long compose(long number)
{
int n=10,m=0;
while (number)
{
int t=number%10;
if(t%2==0)
{
m+=t*n/10;
n*=10;
}
number/=10;
}
return m;
}
void main()
{ long a,b;
printf("Enter a number:");
scanf("%ld",&a);
b=compose(a);
printf("b=%ld\n",b);
}