3-14(Reverse函数)
来源:互联网 发布:php 身份证格式验证 编辑:程序博客网 时间:2024/05/10 21:27
这条题目本来是想用之前的s%10先将数字一个个求出来再倒过来拼在一起输出的,后来发现酱紫如果输入的数字位数不确定就好复杂,如此的话,看到每次s%10的数刚好是按我们要输出的数的顺序出来的,那么就每次让i×10,就可以让其向前进一位,再加上新的余数,如此大功告成!
/* Note:Your choice is C IDE */
#include "stdio.h"int Reverse(unsigned int s)
{
int i;
i=0;
while(s!=0)
{
i=i*10+s%10;
s=s/10;
}
return i;
}
void main()
{
unsigned int s,i;
printf("Please input your number:\n");
scanf("%u",&s);
i=Reverse(s);
printf("%u",i);
}
0 0
- 3-14(Reverse函数)
- 字符串反转(reverse函数)
- STL 反转函数 (reverse() )
- reverse函数
- reverse函数
- reverse函数
- reverse()函数
- hdu——1062Text Reverse(反转函数reverse)
- REVERSE关键字之REVERSE函数
- C语言反转数组(reverse函数)
- Oracle reverse函数
- oracle的reverse函数
- Palindromes+string+reverse()函数
- 倒置字符串函数reverse
- reverse 反转函数原理
- 编制一个函数reverse
- SQL Reverse函数
- 倒置函数reverse
- 十大优秀习惯助你成为优秀程序员
- C++对象模型之数据成员内存布局
- 习题3—21
- mini6410移植--uboot移植(2)
- BZOJ 1503 郁闷的出纳员【NOI2004】
- 3-14(Reverse函数)
- SQL注入的原理,危害及防范
- IOS学习之IOS沙盒(sandbox)机制和文件操作之NSFileManager(三)
- java 面试基础典型题及答案
- hadoop在执行过程中OutOfMemory
- [G+smo] Lsdyna 相关
- mini6410移植--uboot移植(1)
- 我的.Net学习之路三——多态虚方法
- HDU 1800--Flying to the Mars【map】