HDU 1062 Text Reverse
来源:互联网 发布:药品销售人员软件 编辑:程序博客网 时间:2024/06/06 00:16
Text Reverse
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 25464 Accepted Submission(s): 9870
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.HintRemember to use getchar() to read '\n' after the interger T, then you may use gets() to read a line and process it.
Author
Ignatius.L
Recommend
We have carefully selected several similar problems for you: 1020 1073 1039 1040 1088
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;int main(){char s1[1100];char s2[1100];int T,len,i,t,j,k;scanf("%d",&T);getchar();while(T--){gets(s1);len=strlen(s1);for(i=0,j=0,t=0;i<len;i++){if(s1[i]!=' '){s2[j++]=s1[i];}else{if(t>0)printf(" ");for(k=j-1;k>=0;k--)printf("%c",s2[k]);j=0;t++; } if(i==len-1)//输出最后一个单词 { printf(" "); for(k=j-1;k>=0;k--) printf("%c",s2[k]); }}printf("\n");}}
0 0
- hdu 1062 Text Reverse
- hdu 1062 Text Reverse
- HDU 1062 TEXT REVERSE
- Hdu 1062 - Text Reverse
- hdu 1062 Text Reverse
- HDU 1062 Text Reverse
- hdu 1062 Text Reverse
- HDU 1062 Text Reverse
- HDU 1062 - Text Reverse
- hdu 1062 Text Reverse
- hdu 1062 Text Reverse
- Text Reverse(hdu 1062)
- hdu 1062 Text Reverse
- HDU 1062 Text Reverse
- hdu 1062 text reverse
- HDU 1062 Text Reverse
- HDU 1062 Text Reverse
- hdu 1062 Text Reverse
- Android之Activity的生命周期
- C++——多次free和delete导致错误
- 字符串函数的实现
- 未重新服务器而导致的错误java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is
- c++第三次实验——作业
- HDU 1062 Text Reverse
- java反射机制
- UVA - 12186 Another Crisis 水树形dp
- JavaScript编写人机对战五子棋(六)
- View 的位置参数
- 进程的基本属性:进程ID、父进程ID、进程组ID、会话和控制终端
- inet_ntoa之坑------再谈不可重入函数中的static
- 设置web页面favicon设置问题
- 在Eclipse中,使用v7-recyclerview问题