ctci1.4
char* newstr(char * str){
if(str == NULL)
return NULL;
int blank = ;
int len = strlen(str);
int i = ;
for(i = ; i < len ; i++)
if(str[i] == ' ')
blank++;
int j = ;
char * newhead = new char[len + blank* +];
for(i = ; i < len; i++){
if(str[i] != ' ')
newhead[j++] = str[i];
else{
newhead[j++] = '%';
newhead[j++] = '';
newhead[j++] = '';
}
}
newhead[j] = '\0';
str = newhead;
return str;
}
ctci1.4的更多相关文章
- ctci1.8
bool isSub(string str0, string str1){ if(str0.length() != str1.length()) return false; ...
- ctci1.3
; i < len; i++){ if(str0[i] != str1[i]) return false; } return t ...
- ctci1.2
; ; i < len/; i++){ tmp = *(str+i); *(str+i) = *(str+len--i); *(str+l ...
- ctci1.1
) ; ; i < len; i++){ if(place.find(str[i]) == place.end()) place. ...
随机推荐
- TensorFlow学习笔记(三)-- feed_dict 使用
个人理解:就是TF的一种输入语法. 跟C语言的scanf(),C++的 cin>> 意思差不多,只是长相奇怪了点而已. 做完下面几个例子,基本也就适应了. 首先占位符申请空间:使用的时候, ...
- POJ3903Stock Exchange&&POJ1631Bridging signals最长上升子序列 &&POJ1887Testing the CATCHER(最长下降子序列)(LIS模版题)
题目链接:http://poj.org/problem?id=3903 题目链接:http://poj.org/problem?id=1631 题目链接:http://poj.org/problem? ...
- SDUT3143:Combinatorial mathematics(组合数学)
题意:传送门 题目描述 As you know, shadow95 is pretty good at maths, especially combinatorial mathematics. Now ...
- Wilcoxon符号秩+秩和检验学习[转载]
参数检验就是已知数据的精确分布模型,根据数据来求出模型中的未知参数:而非参数检验就是无需对样本总体分布(比如满足正态分布)做出假设. 1.符号检验 转自:https://baike.baidu.com ...
- sql server 复制表从一个数据库到另一个数据库
sql server 复制表从一个数据库到另一个数据库 /*不同服务器数据库之间的数据操作*/ --创建链接服务器 exec sp_addlinkedserver 'ITSV ', ' ', 'SQL ...
- PHP压缩与解压Zip(PHPZip类)
<?php class PHPZip { private $ctrl_dir = array(); private $datasec ...
- javascript 闭包 内存
- PHP闭包(Closure)初探(转载 http://my.oschina.net/melonol/blog/126694?p=2#comments)
匿名函数 提到闭包就不得不想起匿名函数,也叫闭包函数(closures),貌似PHP闭包实现主要就是靠它.声明一个匿名函数是这样: ? 1 2 3 $func = function() { ...
- BZOJ 1316: 树上的询问
挺裸的点分治 刚开始想用map水过去,然后做p次点分治,然后T到自闭 最后发现可以sort一遍,然后去重,记录每个数出现的次数,这样就可以双指针,不会漏掉了 #include <bits/std ...
- python3_ftp文件传输
Python中的ftplib模块 Python中默认安装的ftplib模块定义了FTP类,其中函数有限,可用来实现简单的ftp客户端,用于上传或下载文件 FTP的工作流程及基本操作可参考协议RFC95 ...