矫正单词
来源:互联网 发布:鱼鹰软件可信 编辑:程序博客网 时间:2024/04/27 19:23
1.题目:
Problem Description
LJ likes to write words in reverse way. Given a single line of text which is written by Ignatius, you should reverse all the words and then output them.
Input
The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow.
Each test case contains a single line with several words. There will be at most 1000 characters in a line.
Each test case contains a single line with several words. There will be at most 1000 characters in a line.
Output
For each test case, you should output the text which is processed.
Sample Input
3LJSZnil eij ihs !uhzedam yb .fyb
Sample Output
ZSJLlin jie shi zhu!made by byf.
Author
2.注意事项:
这题主要要注意一个字符串中有多个空格的情况,还有最后的换行的处理。
3.参考代码:
#include <stdio.h>#include <string.h>int main(){ int t, i, j, l, x, y; char s[1000]; while (~scanf("%d%*c", &t)) { while (t--) { gets(s); l = strlen(s); x = 0; y = 0; for (i = 0; i < l; i++) { if (s[i] == ' ') { ///这种情况是有空格的情况 y = i; for (j = y - 1; s[j] != ' ' && j >= 0; j--) printf("%c", s[j]); printf(" "); } else { ///这是没有空格的情况 x++; } } if (x == l) { ///没有空格就逆序输出整个字符串 for (i = l - 1; i >= 0; i--) printf("%c", s[i]); } else { /// 否则处理最后的'\0'的情况 for (j = l - 1; s[j] != ' '; j--) printf("%c", s[j]); } printf("\n"); } } return 0;}
- 矫正单词
- Gamma 矫正
- LDC矫正
- 投影仪矫正
- 贝塞尔矫正
- 方向矫正
- 单词。。
- 单词
- 单词
- 单词
- 单词:
- 单词
- 单词
- 单词
- 单词
- 单词
- 单词
- 单词
- UCS2转UTF-8方法
- hdu 2768 (二分匹配,最大独立集)
- 异地恋的自愈系小故事:企鹅先生和北极熊小姐
- 正编员工:我们就爱这样的实习生
- ajax向后台发送数组数据
- 矫正单词
- Demystifying the Linux Kernel Socket File Systems (Sockfs)
- 2013 多校第一场 hdu 4604 Deque
- Prim 算法求最小生成树
- 注册opc的脚本
- oracle删除重复行
- 火狐插件火狐黑客插件将Firefox变成黑客工具的七个插件
- boost库使用系列(1)---安装
- SQL Server 2008 数据库复制实现数据同步常见问题