哪位能帮我用C语言编下这个程序?谢谢!

来源:百度知道 编辑:UC知道 时间:2024/06/04 19:14:30
输入任意一个整数,将其中的奇数数字组成一个新的数。
如输入:36471238 输出:3713

楼上的不对,要求输入一个整数!
瞧我的:
#include<stdio.h>
void main()
{
long a,b;
int i,n=0,t,aa[10];
scanf("%ld",&a);
b=a;
while(b>0)
{
t=b%10;
b=b/10;
if((t%2)!=0) aa[n++]=t;
}
for(i=n-1;i>=0;i--)
printf("%d",aa[i]);
}
visual c++编译通过,希望能帮助你。

字符数字0,1,2。。。与整形0,1,2。。
相差48。因为0的ascii码为48,1为49。。所以。。。

#include"stdio.h"
#define N 10
main()
{
char s[N],*p;
gets(s);
for(p=s;*p!='\0';p++)
if((*p-48)%2==1)
printf("%d",(*p-48));
}