/*
题目:
将字符串的前sep个字符转移到字符串尾部。
*/
/*
思路:
更好的方法:
先翻转前sep个字符,再翻转后面的字符,最后全体翻转。
*/
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
#include<map> using namespace std; void verse(char* pBegin,char* pEnd){
while(pEnd > pBegin){ char temp = *pBegin;
*pBegin = *pEnd;
*pEnd = temp;
pBegin++;
pEnd--;
}
} char* ReverseSentence(char* pData,int sep){
char* pBegin = pData;
char* pEnd = pData;
int length = 0;
while(*pEnd != '\0'){
pEnd++;
length++;
}
if(sep > length) return nullptr;
pEnd--;
verse(pBegin,pBegin+sep-1);
verse(pBegin+sep,pEnd);
verse(pBegin,pEnd); return pData; } int main(){
char pData[] = "abcdefg";
char* res = ReverseSentence(pData,2);
while(*res != '\0'){
cout<<*res;
res++;
}
}

  

最新文章

  1. Codeforces Round #379 (Div. 2) C. Anton and Making Potions 枚举+二分
  2. Torque2D MIT 学习笔记(27) ---- ImageFont的使用以及字体ImageAsset的工具生成
  3. UI基础UIButton
  4. 读书笔记 effective c++ Item 50 了解何时替换new和delete 是有意义的
  5. 微信退款流程,以及在过程中遇见的错误和解决方式(php 语言)
  6. ES6学习笔记(字符串和数值)
  7. 从零开始的ESP8266探索(1)-使用Server功能搭建Web Server
  8. 斯坦福大学公开课机器学习:machine learning system design | error metrics for skewed classes(偏斜类问题的定义以及针对偏斜类问题的评估度量值:查准率(precision)和召回率(recall))
  9. CSS基础以及属性
  10. javascript宏任务和微任务
  11. 【UVA 11404】Palindromic Subsequence
  12. Docker容器学习梳理 - 容器时间跟宿主机时间同步
  13. 『TensorFlow』迁移学习
  14. Spring Boot + Spring Cloud 实现权限管理系统 后端篇(十一):集成 Shiro 框架
  15. Linux 安装操作系统标准
  16. Spark中cache和persist的区别
  17. Devexpress ChartControl 柱状图简单例子
  18. MySql的InnoDB存储引擎--索引
  19. tensorflow运行出现错误 : ImportError: Could not find &#39;cudart64_90.dll&#39;.
  20. Educational Codeforces Round 45 (Rated for Div. 2) F - Flow Control

热门文章

  1. 1.Vue初始及相关Vue核心组件
  2. Python3-ORM-Sqlalchemy
  3. springIOC源码接口分析(七):ApplicationEventPublisher
  4. idea|properties文件乱码
  5. vue中如何在本地导入js文件
  6. c和c++中读取数据的方式总结
  7. Spring配置 bean
  8. 让Android模拟器速度飞起来_Eclipse+BlueStacks调试Android应用【2012-10-30】
  9. shell脚本 inotify + rsync 同步脚本
  10. git学术