Text Reverse(1062)
来源:互联网 发布:es6类数组对象转数组 编辑:程序博客网 时间:2024/06/03 06:44
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.
#include <stdio.h>#include <string.h>#include <math.h>#include <stdlib.h>#include <ctype.h>int main(){char s[1001];char bu[1001];int i,j,l,flag;int n,c,count;while(scanf("%d",&n)!=EOF){getchar();while(n--){flag=1;count=0;gets(s);l=strlen(s);for(i=0;i<l;i++){if(s[i]==' '){flag=0;break;}}if(flag==1){for(i=l-1;i>=0;i--)printf("%c",s[i]);printf("\n");}else{c=0;for(i=0;i<l;i++){if(s[i]!=' '){bu[c++]=s[i];}else{bu[c]='\0';if(count==0){for(j=c-1;j>=0;j--){printf("%c",bu[j]);}}else{printf(" ");for(j=c-1;j>=0;j--){printf("%c",bu[j]);}}c=0;count++;}}printf(" ");for(j=c-1;j>=0;j--){printf("%c",bu[j]);}printf("\n");}}} return 0;}
0 0
- Text Reverse(1062)
- hdu 1062(Text Reverse)
- hdu——1062Text Reverse(反转函数reverse)
- HDU 1062 Text Reverse (水)
- HDU 1062 Text Reverse(字符串处理)
- HDU 1062 Text Reverse(水~)
- hdu oj 1062 Text Reverse(字符串)
- HDU 1062 Text Reverse(字符串翻转)
- HDU 1062 TEXT Reverse(文本反转)
- HDU-1062-Text Reverse(细节题)
- HDOJ 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
- 对 jiffies 溢出、回绕及 time_after 宏的理解
- Java多线程
- 最近涉猎的东西总结
- 合理应用activity的启动方式优化程序内存(结合android的任务和回退栈)
- hdu-1016 Prime Ring Problem(素数环 dfs)
- Text Reverse(1062)
- Set Maya Laguage
- 题目1117:整数奇偶排序 C++/Java
- 移动开发入门必看——iOS 开发入门书籍推荐
- 线性表的链式存储(双向链表)
- 用线性表来解决约瑟夫环问题(C语言)
- CSS中margin和padding 的理解--学习笔记
- Html常用标签
- wordpress源码解析-数据库表结构(2)