哈理工OJ-2330-Final Ugly English【栈】
2018-02-08 19:32
405 查看
哈理工OJ-2330
Description
ACM twist-toy encountered such a problem in the work, this article, to ensure that this article only lowercase letters
and spaces, please send the articles in each word inverted output, such as “hello world this is an competition”. You
should output “olleh dlrow siht si na noititepmoc”.
Input
A group of data, each line of data input from the lower case letters and spaces of the article, the length of not more than
one thousand
Output
Output a line for each word after the reversal of the article.
Sample Input
hello world this is an competition
Sample Output
olleh dlrow siht si na noititepmoc
题意:
逆序输出字母,看样例
解析:
栈解决一下
Description
ACM twist-toy encountered such a problem in the work, this article, to ensure that this article only lowercase letters
and spaces, please send the articles in each word inverted output, such as “hello world this is an competition”. You
should output “olleh dlrow siht si na noititepmoc”.
Input
A group of data, each line of data input from the lower case letters and spaces of the article, the length of not more than
one thousand
Output
Output a line for each word after the reversal of the article.
Sample Input
hello world this is an competition
Sample Output
olleh dlrow siht si na noititepmoc
题意:
逆序输出字母,看样例
解析:
栈解决一下
#include<bits/stdc++.h> using namespace std; int main() { char a[1111]; while(gets(a)) { stack<char>sta; int len=strlen(a); for(int i=0; i<=len; i++) { if(a[i]==' '||i==len) { while(!sta.empty()) { printf("%c",sta.top()); sta.pop(); } if(i!=len) printf(" "); } else { sta.push(a[i]); } } printf("\n"); } }
相关文章推荐
- 哈理工Final Ugly English(倒置英文)
- Hrbust 2330 Final Ugly English(水题)
- "尚学堂杯"哈尔滨理工大学第七届程序设计竞赛——Hrbust2330 Final Ugly English
- hrbust/哈理工oj 1126 Final Destination II【矩阵快速幂+递推】
- Final Ugly English
- "尚学堂杯"哈尔滨理工大学第七届程序设计竞赛 F Final Ugly English
- "尚学堂杯"哈尔滨理工大学第七届程序设计竞赛 F.Final Ugly English(字符串处理)
- "尚学堂杯"哈尔滨理工大学第七届程序设计竞赛 F.Final Ugly English(字符串处理 4000 )
- 哈理工OJ 2308 Invitations(分形题目)
- [LeedCode OJ]#264 Ugly Number II
- 哈理工oj 1116 解题报告 动态规划-依次输出最长公共子序列的位置
- 哈理工 oj——神奇的进制转换
- 哈理工OJ 2161 数列(数学题目)
- 哈理工 oj 2189 节点的连接
- 哈理工oj 1739 sort problem【思维、水题】
- hrbust 哈理工oj 1360 Leyni的国家III【多路径并查集】
- hrbust 哈理工oj 1588 神医【贪心】
- 哈理工oj/hrbust 2122 旅行【dij+优先队列优化+邻接表+map】
- hrbust 1578 哈理工oj 1578 Prince and little Princess-2【双向队列】
- 哈理工OJ 2255 镇守府海域·镇守府近海(模拟题目)