hdu1062——Text Reverse
来源:互联网 发布:先锋网络电视破解版 编辑:程序博客网 时间:2024/05/16 04:43
原题:
Problem Description
Ignatius 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
3olleh !dlrowm'I morf .udhI ekil .mca
Sample Output
hello world!I'm from hdu.I like acm.
分析:
水题~
原码:
#include<stdio.h>#include<string.h>int main(){ int n,i,j,flag; char str[1005]; scanf("%d",&n); getchar(); while(n--) { gets(str); flag=0; int l=strlen(str); for(i=0; i<l; i++) { if(str[i]==' ') { for(j=i-1; j>=flag; j--) //不用真的翻转,倒序输出就行,当然string使用reverse函数也行 { printf("%c",str[j]); } printf(" "); flag=i+1; } } for(j=l-1; j>=flag; j--) { printf("%c",str[j]); } printf("\n"); } return 0;}
- hdu1062——Text Reverse
- hdu1062(Text Reverse)
- HDU1062:Text Reverse
- Text Reverse hdu1062 水题
- hdu1062 Text Reverse
- HDU1062 Text Reverse
- hdu1062:Text Reverse
- HDU1062 Text Reverse
- Hdu1062 Text Reverse
- hdu1062 - Text Reverse
- hdu1062-Text Reverse
- HDU1062 Text Reverse
- HDU1062 Text Reverse
- HDU1062 Text Reverse
- 面试100题系列之8单词反转 VS HDU1062——text reverse
- hdu1062 Text Reverse (c++输入输出流)
- hdu1062 Text Reverse(C语言)
- HDU 1062 — Text Reverse
- 10041 - Vito's Family
- hdu 2089 不要62和4
- 用php在mysql中,如何截取最大日期和最小日期
- asp.net常用插件
- 如何使用cocos2dx 制作一个多向滚屏坦克类射击游戏-第一部分
- hdu1062——Text Reverse
- Form持久化
- Javascript执行效率小结
- asp.net webForm也可以这样用Ajax -- My Ajax Framework
- 尼玛,罗永浩
- MyEclipse快捷键设置
- CString转char*字符串
- CKEditer实现插入图片的功能
- Min_Cut stoerwagner算法