44.将一个数各个偶数位取出,并从低位往高位输出
2015-06-05 23:07
309 查看
给定程序中,函数fun的功能是:将形参n中,各位上位偶数的书取出,并按原来从高到低位相反的顺序组成一个新的数,并作为函数值得返回。
#include<stdio.h> unsigned long fun(unsigned long n) { unsigned long x = 0; int t; while (n) { t = n % 10; if (t % 2 == 0) x = x * 10 + t; n = n / 10; } printf("%ld\n", x); getchar(); return x; } int main() { unsigned long n = -1; while (n > 99999999 || n < 0) { printf("Please input(0<n<999999999):"); scanf_s("%ld", &n); } printf("\nThe result is:%ld\n", fun(n)); getchar(); return 0; }
相关文章推荐
- rvc
- Android中Menu的基本用法 .
- 【c++】堆排序算法
- 多线程面试秒杀系列6--临界区函数的使用
- [D3] 14. Line and Area Charts with D3
- 第二十篇 人生中的突破口
- Uva 11584 Partitioning by Palindromes(区间dp)
- 2015-06-05
- 多项式相加
- WriteableBitmap/BitmapImage/MemoryStream/byte[]相互转换
- OpenCSP开源程序解析之OPENCSP_Hash.cpp
- JAVA 大数在acm中的应用
- Base64 Base32 Base16全家桶
- codeforces C. Divisibility by Eight (纯属无聊来发一篇博客)
- ct任务添加与中控机批量后台操作
- hdu 5256 序列变换 (LIS变形)
- python虚拟环境的使用
- 操作系统--存储管理的任务
- 操作系统--存储管理的任务
- 初探字符集和字符集编码