编写函数long fun(long x),将长整型参数x中每一位上为偶数的数依次取出,构成一个新数返回.例如:下面程序运行时输入:124578902,程序输出:24802. #includelong fun(long x) { }void main() { long a,b; printf("E
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/04 13:44:55
![编写函数long fun(long x),将长整型参数x中每一位上为偶数的数依次取出,构成一个新数返回.例如:下面程序运行时输入:124578902,程序输出:24802. #includelong fun(long x) { }void main() { long a,b; printf(](/uploads/image/z/3177268-52-8.jpg?t=%E7%BC%96%E5%86%99%E5%87%BD%E6%95%B0long+fun%28long+x%29%2C%E5%B0%86%E9%95%BF%E6%95%B4%E5%9E%8B%E5%8F%82%E6%95%B0x%E4%B8%AD%E6%AF%8F%E4%B8%80%E4%BD%8D%E4%B8%8A%E4%B8%BA%E5%81%B6%E6%95%B0%E7%9A%84%E6%95%B0%E4%BE%9D%E6%AC%A1%E5%8F%96%E5%87%BA%2C%E6%9E%84%E6%88%90%E4%B8%80%E4%B8%AA%E6%96%B0%E6%95%B0%E8%BF%94%E5%9B%9E.%E4%BE%8B%E5%A6%82%EF%BC%9A%E4%B8%8B%E9%9D%A2%E7%A8%8B%E5%BA%8F%E8%BF%90%E8%A1%8C%E6%97%B6%E8%BE%93%E5%85%A5%3A124578902%2C%E7%A8%8B%E5%BA%8F%E8%BE%93%E5%87%BA%3A24802.++++%23includelong+fun%28long+x%29++%7B++%7Dvoid+main%28%29++%7B+long+a%2Cb%3B+printf%28%22E)
编写函数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);
}