当前位置:网站首页>557. 反转字符串中的单词 III
557. 反转字符串中的单词 III
2022-07-30 00:10:00 【Mr Gao】
557. 反转字符串中的单词 III
给定一个字符串 s ,你需要反转字符串中每个单词的字符顺序,同时仍保留空格和单词的初始顺序。
示例 1:
输入:s = “Let’s take LeetCode contest”
输出:“s’teL ekat edoCteeL tsetnoc”
示例 2:
输入: s = “God Ding”
输出:“doG gniD”
这题比较常规的,解题代码如下:
void f(char *s,int length){
int i;
for(i=0;i<length/2;i++){
/// printf("--%c %c",s[i],s[length-1-i]);
char t=s[i];
s[i]=s[length-1-i];
s[length-1-i]=t;
}
}
char * reverseWords(char * s){
int start=0;
int i;
for( i=0;s[i]!='\0';i++){
// printf("%c ",s[i]);
if(s[i]==' '){
int length=i-start;
printf(" -- %d %d %d %c",start,i,length,s[start]);
f(s+start,length);
start=i+1;
}
}
int length=i-start;
f(s+start,length);
return s;
}
边栏推荐
- 2022/7/29 Exam Summary
- 随便记记第二周
- 图论:二分图
- Worthington解离酶:胶原酶及四个基本概况
- Worthington细胞分离技术丨基本原代细胞分离方法和材料
- Worthington Enzymatic Cell Harvest & Cell Adhesion and Harvest
- Since the media increase play a short video?From the three aspects
- C陷阱与缺陷 第4章 链接 4.3 命名冲突与static修饰符
- 【集训DAY18】Welcome J and Z 【动态规划】
- BEVDetNet: Bird's Eye View LiDAR Point Cloud based Real-time 3D Object Detection for Autonomous Drivi
猜你喜欢

学会使用MySQL的Explain执行计划,SQL性能调优从此不再困难
![CesiumJS 2022^ 源码解读[0] - 文章目录与源码工程结构](/img/6a/0a446eb00fb73275897cbfb336e0b0.png)
CesiumJS 2022^ 源码解读[0] - 文章目录与源码工程结构

窗口函数笔记

全网最强 JVM 来袭!(至尊典藏版)

『牛客|每日一题』走迷宫

At the age of 29, I was fired from a functional test. Can't find a job after 2 months of interviews?

论文精读——YOLOv3: An Incremental Improvement

MySQL 用 BETWEEN AND 日期查询包含范围边界

EA&UML日拱一卒-多任务编程超入门-(2)进程和线程

4 hotspot inquiry networks necessary for new media operations
随机推荐
“ 我是一名阿里在职9年软件测试工程师,我的经历也许能帮到处于迷茫期的你 ”
ApplicationContext的三大实现
头条号自媒体运营:如何在今日头条涨500+粉丝?
Worthington Papain & Chymotrypsin & DNase I
重写并自定义依赖的原生的Bean方法
First Normal Form, Second Normal Form, Third Normal Form
定时器学习
EA & UML Sun Arch - State Diagram :: Redraw Button State Diagram
Chinese semantic matching
Add, delete, modify and query the database
He used to cells harvested trypsin & release procedure
How to design and implement report collaboration system for instruction set data products——Development practice of industrial collaborative manufacturing project based on instruction set IoT operating
SQL Server、MySQL主从搭建,EF Core读写分离代码实现
Worthington Optimized Technology: Cell Quantification
指令集数据产品如何设计和实现报表协同系统——基于指令集物联网操作系统的工业协同制造项目开发实践
低压差线性稳压器MPQ2013A-AEC1品牌MPS国产替代
One article to answer web performance optimization
Low dropout linear regulator MPQ2013A-AEC1 brand MPS domestic replacement
Worthington木瓜蛋白酶&胰凝乳蛋白酶&脱氧核糖核酸酶 I
某团实习面经