C语言 反序打印字符串中的单词
int main()
{
char *str = "see you later";
int r = strlen(str);
char * p = str;
int a= ;
while(*str++!='\0')
{
if(*str == ' ')
{
a++;
}
}
str-=(r+);
int arr[a];
int i,j;
for(i =,j=;i<r;i++)
{
if(*str ==' ')
{
arr[j] = i;
j++;
}
str++;
}
str-=(r-);
//puts(p+arr[1]);
char arr2[r+];
int k = ;
puts(p);
while(*str!='\0')
{
if(*str == ' ')
{
arr2[k] = '\0';
}
else
{
arr2[k] = *str;
}
str++;
k++;
}
arr2[k] = '\0';
p = arr2;
for(i = a-;i>=;i--)
{
puts(p+arr[i]);
}
puts(p); return ;
}
C语言 反序打印字符串中的单词的更多相关文章
- [LeetCode] Reverse Words in a String 翻转字符串中的单词
Given an input string, reverse the string word by word. For example, Given s = "the sky is blue ...
- [Swift]LeetCode434. 字符串中的单词数 | Number of Segments in a String
Count the number of segments in a string, where a segment is defined to be a contiguous sequence of ...
- Leetcode#557. Reverse Words in a String III(反转字符串中的单词 III)
题目描述 给定一个字符串,你需要反转字符串中每个单词的字符顺序,同时仍保留空格和单词的初始顺序. 示例 1: 输入: "Let's take LeetCode contest" 输 ...
- 力扣(LeetCode)字符串中的单词数 个人题解
统计字符串中的单词个数,这里的单词指的是连续的不是空格的字符. 请注意,你可以假定字符串里不包括任何不可打印的字符. 示例: 输入: "Hello, my name is John" ...
- [LeetCode] 151. Reverse Words in a String 翻转字符串中的单词
Given an input string, reverse the string word by word. For example,Given s = "the sky is blue& ...
- leetcode434 字符串中的单词树(python)
统计字符串中的单词个数,这里的单词指的是连续的不是空格的字符. 请注意,你可以假定字符串里不包括任何不可打印的字符. 示例: 输入: "Hello, my name is John" ...
- [LeetCode] Reverse Words in a String II 翻转字符串中的单词之二
Given an input string, reverse the string word by word. A word is defined as a sequence of non-space ...
- [Swift]LeetCode557. 反转字符串中的单词 III | Reverse Words in a String III
Given a string, you need to reverse the order of characters in each word within a sentence while sti ...
- C#版(击败97.76%的提交) - Leetcode 557. 反转字符串中的单词 III - 题解
版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. Leetcod ...
随机推荐
- bzoj1263: [SCOI2006]整数划分(高精度+构造)
第一次写压位高精度只好抄黄学长的 代码最后一段想了好久一看评论区才知道黄学长写错了= =很气 自己最后改对了T^T 这题最优是一直划分3出来直到<=4 #include<iostream& ...
- 【树状数组】【P2345】 奶牛集会
传送门 Description 约翰的\(N\)头奶牛每年都会参加"哞哞大会".哞哞大会是奶牛界的盛事.集会上的活动很多,比如堆干草,跨栅栏,摸牛仔的屁股等等.它们参加活动时会聚在 ...
- java使用POI操作XWPFDocument中的XWPFParagraph(段落)对象的属性略解
我用的是office word 2016版 创建文本对象 XWPFDocument docxDocument = new XWPFDocument(); 创建段落对象 XWPFParagraph pa ...
- iOS AFNetworking 2.6.0框架导入报错解决方法
最近手动导入AFNetworking 2.6.0框架时发现Xcode报如下3个错误: 1. Use of undeclared identifier ‘kSecFormatUnknown‘ 2. Us ...
- [solr]solr的安装
solr是什么? 翻译: SolrTM is the popular, blazing fast open source enterprise search platform from the Apa ...
- RotateAnimation 详解
RotateAnimation 详解 看看新闻网>看引擎>开源产品 其他构造器的旋转也可参考这副图. RotateAnimation旋转坐标系为以旋转点为坐标系(0,0)点.x轴为0度,顺 ...
- 在windows下如何使用密钥对远程登录服务器?
在企业的生产中相信各位朋友都会使用远程登录服务器,这样即高效也非常方便,(服务器在西藏,没有远程技术,公司在北京,你只能到西藏与机器相伴,在这里我使用xshell软件),我们使用ssh 服务登录服务器 ...
- Maven命令创建java项目
------------------------------java项目搭建--------------------------- 使用Maven构建一个简单的Java项目 1.进入命令行,执行下面的 ...
- MySQL查询 45道练习题
SQL查询45道练习题 1.查询Student表中的所有记录的Sname.Ssex和Class列.select sname,ssex,class from student2.查询教师所有的单位即不重复 ...
- word-wrap word-break 区别
word-wrap word-break 区别 word-break * word-break:break-all;//直接把单词截断 * word-break:break-word;//虽然单词截断 ...