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 ...
随机推荐
- HDOJ(HDU).1035 Robot Motion (DFS)
HDOJ(HDU).1035 Robot Motion [从零开始DFS(4)] 点我挑战题目 从零开始DFS HDOJ.1342 Lotto [从零开始DFS(0)] - DFS思想与框架/双重DF ...
- Dynamic Rankings——带修改区间第k大
三种做法:1.整体二分: 二分mid 考虑小于mid的修改的影响 但是大于mid的修改可能会干掉小于mid的一些值 所以额外把一个修改变成一个值的删除和一个值的添加 这样就相互独立了! 整体二分,树状 ...
- 题解【luoguP4145 上帝造题的七分钟2(花神游历各国)】
题目链接 题解 题目大意: 一个序列,支持区间开方与求和操作. 算法:线段树实现开方修改与区间求和 分析: 显然,这道题的求和操作可以用线段树来维护 但是如何来实现区间开方呢 大家有没有这样的经历:玩 ...
- DOM基本代码二
------------------------------- <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xh ...
- Jenkins自动化构建系列:01敏捷开发、自动化构建与持续集成
<SVN与TortoiseSVN实战系列>已写完,今天新开一个<Jenkins自动化构建系列>,上周听了Bob Jiang老师的Agile1001公开课,一直想写个总结,这篇关 ...
- 获取Web.Config中节点的值
读取webconfig里面的appSetting和connectionString <appSettings> <add key="SiteURL" value= ...
- Azure Pipelines
https://docs.microsoft.com/en-us/azure/devops/pipelines/?view=vsts
- Shell脚本循环读取文件中的每一行
1.使用for循环 for line in `cat filename` do echo $line done 2.使用for循环 for line in $(cat filename) do ech ...
- [技巧篇]21.Android Studio的快捷键设置[图片版]
如果对你有帮助,请点击推荐!
- Test Index
top1 top11 top2 top1 top11 top2