编写函数long fun(long x),将长整型参数x中每一位上为偶数的数依次取出,构成一个新数返回.例如:下面程序运行时输入:124578902,程序输出:24802. #includelong fun(long x) { }void main() { long a,b; printf("E

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/02 19:05:52
编写函数long fun(long x),将长整型参数x中每一位上为偶数的数依次取出,构成一个新数返回.例如:下面程序运行时输入:124578902,程序输出:24802.    #includelong fun(long x)  {  }void main()  { long a,b; printf(

编写函数long fun(long x),将长整型参数x中每一位上为偶数的数依次取出,构成一个新数返回.例如:下面程序运行时输入:124578902,程序输出:24802. #includelong fun(long x) { }void main() { long a,b; printf("E
编写函数long fun(long x),将长整型参数x中每一位上为偶数的数依次取出,构成一个新数返回.
例如:下面程序运行时输入:124578902,程序输出:24802.
#include
long fun(long x)
{
}
void main()
{ long a,b;
printf("Enter a number:");
scanf("%ld",&a);
b=fun(a);
printf("b=%ld\n",b);
}

编写函数long fun(long x),将长整型参数x中每一位上为偶数的数依次取出,构成一个新数返回.例如:下面程序运行时输入:124578902,程序输出:24802. #includelong fun(long x) { }void main() { long a,b; printf("E
#include
long fun(long x)
{
int n=10,m=0;
while (x)
{
int t=x%10;
if(t%2==0)
{
m+=t*n/10;
n*=10;
}
x/=10;
}
return m;
}
void main()
{ long a,b;
printf("Enter a number:");
scanf("%ld",&a);
b=fun(a);
printf("b=%ld\n",b);
}