我把函数给你写出来,你自己写主程序:
/*取x的奇数位返回*/
long fun(long x){
long y,u;
y=0;/*返回数*/
u=1;/*个为、百位、万位的循环*/
while (x>u){
y=((x/u)%10)*u;/*取x的u位,并加到y上*/
u=u*100;
}
}
main()
{
long int a, b=0, n=1;
printf("please enter the number: \n");
scanf("%ld",&a);
for(;a;)
{
b+=n*(a%10);
a=a/100;
n*=10;
}
printf("\n%ld\n",b);
getch();
}
#include
#include
#include
#include
int main(int argc, char **argv)
{
long s, t, a, c;
if (argc < 2) {
printf("syntax: %s
return 1;
}
s = atol(argv[1]);
t = 0;
c = 1;
while (s) {
a = s % 10;
s /= 100;
t += a * c;
c *= 10;
}
printf("result=%ld\n", t);
return 0;
}
#include
long fun( long x )
{
long t = 0 ;
if( x == 0 )
return 0 ;
if( x % 2 == 0 )
return fun( x/10 );
else
return fun( x/10 ) * 10 + x%10 ;
}
int main()
{
long x , t ;
scanf("%ld",&x);
t = fun( x ) ;
printf("%ld\n",t);
return 0 ;
}