atoi和itoa的实现
来源:互联网 发布:贴吧 回复淘宝链接 编辑:程序博客网 时间:2024/06/05 09:38
atoi
int atoi(char* in){ int sign=1; if(*in == '-') sign=-1; int sum=0; in++; while(*in!='\0') { sum=sum*10+(*in-'0'); in++; } return sum*sign;}
itoa
void itoaa(int value, char* str){ if(value<0) { str[0]='-'; value=value*-1; } int j=1; for(int i=value; i>0; i/=10, j++) { int n=i%10; str[j]=n+'0'; } str[j]='\0'; j--; int n=j/2; for(int i=1; i<=n; i++, j--) { str[i]=str[i]^str[j]; str[j]=str[i]^str[j]; str[i]=str[i]^str[j]; }}
扩展问题:
不借助额外空间交换两个变量的值
A^=B^=A^=B
- atoi和itoa的实现
- atoi和itoa的实现
- atoi 和itoa的实现
- atoi和itoa的实现
- atoi 和 itoa的实现
- atoi和itoa的实现
- atoi 和itoa实现
- atoi 和 itoa实现
- 实现itoa()和atoi()
- atoi() itoa() 的实现
- atoi和itoa的C实现
- atoi()和itoa()的标准源码实现
- atoi()和itoa()的标准源码实现
- atoi和itoa的C++实现
- atoi()和itoa()的标准源码实现
- atoi和itoa函数的实现
- atoi和itoa的编程实现
- atoi和itoa函数的实现方法
- linux smb
- 第一篇文章
- 一个文件工具类
- Java事务开发常见问题
- The type 'System.Data.Objects.DataClasses.EntityObject' is defined in an assembly that is not refere
- atoi和itoa的实现
- dos 路径取得
- python 模块学习链接
- protege中使用推理机
- sqlalchemy-连接mysql数据库
- GSM IMSI组成结构
- Android UI thread / main thread
- asp.net 模式窗口用法 window.showModalDialog()
- enum与typedef enum的用法