Text Reverse(hdu 1062)
来源:互联网 发布:韩春雨造假知乎 编辑:程序博客网 时间:2024/04/27 19:39
Text Reverse
TimeLimit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K(Java/Others)Total Submission(s): 7906 Accepted Submission(s):3015
Problem Description
Ignatius likes to write words in reverseway. Given a single line of text which is written by Ignatius, youshould 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 thenumber of test cases. T test cases follow.
Each test case contains a single line with several words. Therewill be at most 1000 characters in a line.
Each test case contains a single line with several words. Therewill be at most 1000 characters in a line.
Output
For each test case, you should outputthe text which is processed.
Sample Input
3 olleh!dlrow m'I morf .udh I ekil .mca
Sample Output
helloworld! I'm from hdu. I like acm.
Hint
Remember to use getchar() to read '\n' after the interger T, thenyou may use gets() to read a line and process it.Author
Ignatius.L
#include<iostream>#include <stdio.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <algorithm> using namespace std;int main(){ intt,i,j,k,r,s; charstr[1005],out[1005]; scanf("%d",&t); getchar(); while(t--){ memset(str,'\0',sizeof(str)); memset(out,'\0',sizeof(out)); gets(str); for(i=0,k=0;i<=strlen(str);i++) if(str[i]==' '||str[i]=='\0'){ r=i-k; for(j=i-1,s=0;s<r;s++,j--,k++) out[k]=str[j]; if(k<strlen(str)) out[k]=' '; k++; } puts(out); } return0;}
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
- FATE(hdu 2159)
- Bone Collector(hdu 2602)
- Strange fuction(hdu 2899)
- Can you find it?(hdu 2141)
- More is better(hdu 1856)
- Text Reverse(hdu 1062)
- 密码(hdu 2043)
- 统计元音(hdu 2027)
- DFS之全排列
- Humble Numbers(hdu1058)
- 剪枝问题
- VS2010/MFC编程入门之十一(对话框:非模态对话框的创建及显示)
- 普通母函数
- Dijkstra算法