网站首页 美食营养 游戏数码 手工爱好 生活家居 健康养生 运动户外 职场理财 情感交际 母婴教育 时尚美容

C长整型数中各位上为奇数的数依次取出构成新数.

时间:2024-10-15 04:29:40

1、打开Dev-C++

C长整型数中各位上为奇数的数依次取出构成新数.

3、写好主函数

C长整型数中各位上为奇数的数依次取出构成新数.

5、完整代码#include<stdio.h>void fun(long s,long *t){ int d; long sl=1; *t= 0; while(s>0) { d=s%10; if (d%2 == 1) { *t = d * sl + *t; sl *= 10; } s /= 10; }}void main(){ long s,t; printf("\nPlease enter s:"); scanf("%ld", &s); fun(s, &t); printf("The result is: %ld\n", t);}

C长整型数中各位上为奇数的数依次取出构成新数.
© 2025 小知经验
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com