例題:下列給定程式中函式fun的功能是:從低位開始取出長整型變數a中奇數位上的數,依次構成一個新數放在b中,
例如,當a中的數為7654321時,則b中的數為7531,
注意:不要改動main函式,不能增行或刪行,也不能更改程式的結構,
代碼如下:
#include<conio.h>
#include<stdio.h>
void fun(long a,long*b)
{
long s1=10;
*b=a%10;
while(a>0)
{
a=a/100;
*b=a%10*s1+*b;
s1=s1*10;
}
}
main()
{
long a,b;
printf("\nPlease enter data:");
scanf("%ld",&a);
fun(a,&b);
printf("The result is:%ld\n",b);
}
輸出運行視窗如下:

越努力越幸運!
加油,奧力給!!!
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/255903.html
標籤:其他
