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 ...
随机推荐
- 牛客网 提高组第8周 T1 染色
染色 链接: https://ac.nowcoder.com/acm/contest/176/A 来源:牛客网 题目描述 \(\tt{fizzydavid}\)和\(\tt{leo}\)有\(n\)个 ...
- UVA.11636 Hello World! (思维题)
UVA.11636 Hello World! (思维题) 题意分析 这题挺水的,还是错了几发. QWQ. 有一个同学打了一行hello world,现在他想打n行hello world,请问最少复制粘 ...
- 题解 【luogu P2680 NOIp提高组2015 运输计划】
题目链接 题解 题意 一棵树上有\(m\)条路径,可以将其中一条边的权值改为0,问最长的路径最短是多少 分析 最短的路径最长自然想到二分最长路径,设其为\(dis\) 关键在于如何check chec ...
- mybatis中association和collection的column传入多个参数值
在使用 association和collection 进行关联查询的时候 column 参数可能会有多个,如下: 注意: parameterType 一定要是 java.util.Map
- 使用 log4j 在控制台 打印 hibernate 语句参数
log4j.rootLogger=INFO, stdoutlog4j.appender.stdout=org.apache.log4j.ConsoleAppenderlog4j.appender.st ...
- poj 3376 Finding Palindromes
Finding Palindromes http://poj.org/problem?id=3376 Time Limit: 10000MS Memory Limit: 262144K ...
- Spring Boot 启动报错:LoggingFailureAnalysisReporter
17:57:19: Executing task 'bootRun'... Parallel execution with configuration on demand is an incubati ...
- freemarker中空值“”,null值的判断
原文:http://zhousheng193.iteye.com/blog/1319772 <#if letVo.manageScore!=""> ${html('${ ...
- bzoj 1696: [Usaco2007 Feb]Building A New Barn新牛舍 ——中位数排序
Description 经过多年的积蓄,农夫JOHN决定造一个新的牛舍.他知道所有N(2 <= N <= 10,000)头牛的吃草位置,所以他想把牛舍造在最方便的地方. 每一头牛吃草的位置 ...
- JS之递归(例题:猴子吃桃)
例题1:公园里有200个桃子,猴子每天吃掉一半以后扔掉一个,问6天以后还剩余多少桃子? var sum = 200; for(var i= 0;i<6;i++) { sum = parseInt ...