HDU 1062 Text Reverse【栈 翻转操作】
来源:互联网 发布:咕咚运动软件 编辑:程序博客网 时间:2024/06/07 07:36
Text Reverse
Time Limit: 20001000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 23566 Accepted Submission(s): 9079
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.
标记一个位置,然后直接倒序输出,模拟栈的效果.....
#include<stdio.h>#include<string.h>int main(){char s[10005];int t;scanf("%d",&t);getchar();while(t--){gets(s);int len=strlen(s),sign=0;for(int i=0;i<=len;++i){if(s[i]==0||s[i]==' '){if(sign){printf(" ");}for(int j=i-1;j>=sign;--j){printf("%c",s[j]);}sign=i+1;}}printf("\n");}return 0;}
0 0
- HDU 1062 Text Reverse【栈 翻转操作】
- HDU 1062 Text Reverse(字符串翻转)
- HDOJ/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
- hdu 1062 Text Reverse
- Text Reverse(hdu 1062)
- hdu 1062 Text Reverse
- HDU 1062 Text Reverse
- hdu 1062 text reverse
- ANDROID版本号和版本名称
- 4.7.1. Default Argument Values(默认参数)
- Vmware PING本地虚拟机
- 根本上解决“LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏”问题
- Quartz 2D的坐标系和UIKit的坐标系对比以及相互转换
- HDU 1062 Text Reverse【栈 翻转操作】
- Makefile 初学
- Modbus disconnected
- UICollectionView之定制UICollectionViewLayout
- android studio 修改默认的 debug.keystore
- SqlServer内存瓶颈分析--SQLServer:Buffer Manager
- 最简单也最难——如何获取到Android控件的高度,获取android控件
- 【加密算法】3DES加密算法
- Linux 抓USB包