当前位置:网站首页>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;
}
边栏推荐
- Minesweeper game in c language
- Worthington弹性蛋白酶&透明质酸酶简介
- Sentinel入门
- “灯塔工厂”的中国路径:智造从点到面铺开
- 图论:二分图
- 新媒体运营必备的4个热点查询网
- The strongest JVM in the whole network is coming!(Extreme Collector's Edition)
- Worthington Dissociation Enzymes: Trypsin and Frequently Asked Questions
- vmtouch——Linux下的文件缓存管理神器
- EA & UML Sun Arch - State Diagram :: Redraw Button State Diagram
猜你喜欢
Worthington Dissociation Enzymes: Trypsin and Frequently Asked Questions
Elephant Swap:借助ePLATO提供加密市场的套利空间
Worthington酶促细胞收获&细胞粘附和收获
vim相关介绍(二)
Elephant Swap: Provide arbitrage space in the crypto market with ePLATO
【集训DAY16】KC‘s Can 【动态规划】
CesiumJS ^ source read [0] 2022 - article directory and source engineering structure
多商户商城系统功能拆解18讲-平台端商家售后
From the perspective: the interviewer interview function test engineer mainly inspects what ability?
经典论文-SqueezeNet论文及实践
随机推荐
Since the media increase play a short video?From the three aspects
Genesis与Axis Ventures互动密切
what is a .pro file in qt
Worthington解离酶:中性蛋白酶(分散酶)详情解析
Getting Started with Sentinel
抖音短视频流量获取攻略,掌握好这些一定可以出爆款
软件测试拿8k以上有多简单,掌握这些随随便便拿8k以上...
Music theory & guitar skills
The basic parallel I/O port of single chip microcomputer development
“灯塔工厂”的中国路径:智造从点到面铺开
CesiumJS ^ source read [0] 2022 - article directory and source engineering structure
每周推荐短视频:研发效能是什么?它可以实现反“内卷”?
KDE Frameworks 5.20.0: Plasma welcomes many improvements
jenkins搭建部署详细步骤
【云原生Kubernetes】二进制搭建Kubernetes集群(中)——部署node节点
C陷阱与缺陷 第4章 链接 4.1 什么是链接器
第一范式、第二范式、第三范式
Worthington Dissociation Enzymes: Collagenase and Four Basic Profiles
头条号自媒体运营:如何在今日头条涨500+粉丝?
Worthington dissociating enzyme: detailed analysis of neutral protease (dispase)