void ReplaceBlank(char str[], int length) // length >= the real length of string
{
if (str == nullptr || length <= )
{
return;
}
int origin_str_len = ;
int new_str_len = ;
int i = ;
int count_space = ;
while (str[i] != '\0')
{
if (str[i] == ' ')
++count_space;
++origin_str_len;
++i; }
new_str_len = origin_str_len + * count_space;
if (new_str_len > length)
return; while (origin_str_len >= && new_str_len > origin_str_len)
{
if (str[origin_str_len] == ' ')
{
str[new_str_len--] = '';
str[new_str_len--] = '';
str[new_str_len--] = '%'; }
else
{
str[new_str_len--] == str[origin_str_len];
}
--origin_str_len;
} }

<OFFER05> 05_ReplaceSpaces的更多相关文章

  1. 【算法训练营day8】LeetCode344. 反转字符串 LeetCode541. 反转字符串II 剑指Offer05. 替换空格 LeetCode151. 翻转字符串里的单词 剑指Offer58-II. 左旋转字符串

    [算法训练营day8]LeetCode344. 反转字符串 LeetCode541. 反转字符串II 剑指Offer05. 替换空格 LeetCode151. 翻转字符串里的单词 剑指Offer58- ...

  2. 剑指Offer05 用栈模拟队列

    添加了模板类应用 /************************************************************************* > File Name: ...

随机推荐

  1. mysql获取下一篇和上一篇文章的ID

    mysql获取上一篇和下一篇文章的ID只要在当前页面读取上一个和下一个的ID就可以了.假设当前ID为10:搜索上一个的ID:select  id  from table where id<10 ...

  2. laravel教程入门笔记

    安装laravel框架 1.安装命令 composer create-project --prefer-dist laravel/laravel ytkah ytkah表示文件夹名,如果不写的话自动会 ...

  3. 移除wordpress版本信息 删除无用信息

    wordpress页面头部有很多无用的信息,像wordpress版本信息.feed等,如何把它们删除或不让它们先是出来呢? 将下面的代码加入到当前主题的functions.php,可以适当酌情保留 & ...

  4. js-jquery-Validate校验【一】

    一.导入 js 库 <script src="http://static.runoob.com/assets/jquery-validation-1.14.0/lib/jquery.j ...

  5. PAT 1030 Travel Plan[图论][难]

    1030 Travel Plan (30)(30 分) A traveler's map gives the distances between cities along the highways, ...

  6. PAT Counting Leaves[一般]

    1004 Counting Leaves (30)(30 分) A family hierarchy is usually presented by a pedigree tree. Your job ...

  7. storm介绍,核心组件,编程模型

    一.流式计算概念 利用分布式的思想和方法,对海量“流”式数据进行实时处理,源自业务对海量数据,在“时效”的价值上的挖掘诉求,随着大数据场景应用场景的增长,对流式计算的需求愈发增多,流式计算的一般架构图 ...

  8. soapUI-Conditional Goto

    1.1.1  Conditional Goto 1.1.1.1 概述 - Conditional Goto Conditional Goto TestStep包含任意数量的XPath/JSONPath ...

  9. 使用block的好处

    1 使用block 可以轻松地绑定各处代码块,使用delete 结构是分散的,不利于变量之间传值,不像block可以随意地获取变量值. 2.使用block可以方便执行异步代码,作为异步处理回调. In ...

  10. codefirst configuration

    codefirst 书写配置类,用于entity与数据库中表或view映射 1.对应表或视图都用this.ToTable("SimpleCompanyLoanView", &quo ...