例题:下列给定程序中函数fun的功能是:从低位开始取出长整型变量x中偶数位上的数,依次构成一个新数放在y中。
例如,当x中的数为123456时,则y中的数应为135。
注意:不要改动main函数,不能增行或删行,也不能更改程序的结构。
代码如下:
#include<conio.h>
#include<stdio.h>
void fun(long x,long*y)
{
long t=10;
x/=10;
*y=x%10;
while(x>0)
{
x=x/100;
*y=x%10*t+*y;
t=t*10;
}
}
main()
{
long x,y;
printf("\nPlease enter s:");
scanf("%ld",&x);
fun(x,&y);
printf("The result is:%ld\n",y);
}
输出运行窗口如下:
越努力越幸运!
加油,奥力给!!!