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的更多相关文章

  1. ctci1.8

    bool isSub(string str0, string str1){     if(str0.length() != str1.length())         return false;   ...

  2. ctci1.3

    ; i < len; i++){         if(str0[i] != str1[i])             return false;     }          return t ...

  3. ctci1.2

    ;     ; i < len/; i++){         tmp = *(str+i);         *(str+i) = *(str+len--i);         *(str+l ...

  4. ctci1.1

    )         ;     ; i < len; i++){         if(place.find(str[i]) == place.end())             place. ...

随机推荐

  1. Docker中安装配置Oracle数据库

    本文使用的OS是Ubuntu([16.04.1_server][1])[注:Ubuntu是安装在vmware虚拟机上的]. 其他的Oracle连接工具:[sqldeveloper-4.1.5.21.7 ...

  2. python学习笔记(二)文件操作和集合

    集合: 集合也是一种数据类型,一个类似列表东西,它的特点是无序的,不重复的,也就是说集合中是没有重复的数据 集合的作用: 1.它可以把一个列表中重复的数据去掉,而不需要你再写判断 2.可以做关系测试, ...

  3. Lua4.0中getn陷阱

    Lua4.0中getn潜规则 • 使用t[n] = nil方式删除元素会导致意外结果 t = {, , , , , , , , , }; t[] = nil; t = {, , , , , , , , ...

  4. php 通过http user-agent判断是否为手机浏览器

    <?php/*** 判断是否是通过手机访问* @return bool 是否是移动设备    */public function isMobile() {  //判断手机发送的客户端标志  if ...

  5. 使用cygwin移植Linux的项目到Windows下之总结(转)

    使用cygwin移植Linux的项目到Windows下之总结(转) 原文 http://my.oschina.net/michaelyuanyuan/blog/68615?p=1   一.why   ...

  6. 自动填写IE的网页的输入框的内容

    procedure TForm1.PutData; var ShellWindow: IShellWindows; nCount: integer; spDisp: IDispatch; i,j,X: ...

  7. jQuery动态效果学习笔记

    资料来源 W3Cschool 1.元素的显示与隐藏 1.1显示元素show() 语法 $(selector).show(speed,callback); 显示已经设置隐藏的元素 1.2隐藏元素hide ...

  8. Git在Githib和Github上的使用

    本文使用的环境是linux里 一.git的常用命令解释: 1.基础命令: git init #创建版本库 git add <file> #将文件修改添加到暂存区 git commit -m ...

  9. 命令查看java的class字节码文件

    源代码: public class Math { public static void main(String[] args){ int a=1; int b=2; int c=(a+b)*10; } ...

  10. asp.net时间显示

    DateTime dt = DateTime.Now;//    Label1.Text = dt.ToString();//2005-11-5 13:21:25//    Label2.Text = ...