字符串基本操作2
来源:互联网 发布:js方法同步执行 编辑:程序博客网 时间:2024/06/01 13:46
//排序字符串,使得字符串大写在前,小写在后void StrSort(char* s){int len=0;while(s[len]!='\0')len++;int index=-1;for(int i=0;i<len;i++){if(s[i]>='A'&&s[i]<='Z'){char tem=s[++index];s[index]=s[i];s[i]=tem;}}}
#include<limits>/* * 实现atoi函数 * 1.数值越界 * 2.正负数 * 3.字符串结束标志 * */int StringToInt(string& str){if(str.length()==0)return 0;//清除空格int i=0;for(;str[i]!=' ';i++)break;//设置符号标志位bool flag=false;if(str[i]=='-'){i++;flag=true;}//转整数int result=0;for(;str[i]!='\0';i++){if(str[i]<'0'||str[i]>'9')return 0;int tem = str[i]-'0';if(!flag && numeric_limits<int>::max()-result*10<=tem)return numeric_limits<int>::max();if(flag && numeric_limits<int>::min()+result*10>=tem*-1)return numeric_limits<int>::min();result=result*10+tem;}if(flag)return 0-result;elsereturn result;}
0 0
- 字符串基本操作2
- Bash基本字符串操作
- 字符串基本操作
- perl 字符串基本操作
- 字符串基本操作
- 字符串的基本操作
- 字符串基本操作
- 字符串基本操作
- 字符串的基本操作
- 字符串的基本操作
- 字符串的基本操作
- 字符串基本操作
- 基本字符串操作函数
- 字符串的基本操作
- 基本的字符串操作
- 字符串基本操作
- 字符串基本操作
- 字符串基本操作集锦
- POJ 3281 Dining 【网络流建模汇总】最大流
- OpenCV_连通区域分析(Connected Component Analysis/Labeling)
- CentOS7更改yum软件源
- 在应用内部打开WebView
- iPhone开发 Label,button,view,window控件的添加
- 字符串基本操作2
- Android中OkHttp使用
- 将单链表拆分为两个特定的单链表
- Base64&&Md5加密算法计算头部与sig
- ES5对Array增强的9个API
- Nginx 与Tomcat 实现动静态分离和负载均衡
- springmvc validator验证的使用
- 逆矩阵及其矩阵线性一元方程的简单算法
- 接触了解Java