stack的使用-Hdu 1062
Text Reverse
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 51495 Accepted Submission(s): 19692
Each test case contains a single line with several words. There will be at most 1000 characters in a line.
#include <bits/stdc++.h> using namespace std; int main()
{
int n;
char ch;
cin>>n;
getchar();
while(n--){
stack<char>s;
while(true){
ch = getchar();
if(ch==' '||ch=='\n'||ch==EOF){
while(!s.empty()){
cout<<s.top();
s.pop();
}
if(ch=='\n'||ch==EOF)
break;
cout<<" ";
}
else
s.push(ch);
}
cout<<endl;
}
return ;
}
stack的使用-Hdu 1062的更多相关文章
- HDU 1062 Text Reverse(水题,字符串处理)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1062 解题报告:注意一行的末尾可能是空格,还有记得getchar()吃回车符. #include< ...
- hdu 1062 Text Reverse 字符串
Text Reverse Time L ...
- 题解报告:hdu 1062 Text Reverse
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1062 Problem Description Ignatius likes to write word ...
- HDU 1062 Text Reverse
题意 : 给出你一个句子,让你把句子中每个单词的字母顺序颠倒一下输出. 思路 : 用栈即可,就是注意原来在哪儿有空格就要输出空格. //hdu1062 #include <iostream> ...
- HDOJ/HDU 1062 Text Reverse(字符串翻转~)
Problem Description Ignatius likes to write words in reverse way. Given a single line of text which ...
- [hdu 1062] Text Reverse | STL-stack
原题 题目大意: t组数据,每组为一行,遇到空格时讲前面的单词反转输出. 题解: 显然的栈题,遇到空格时将当前栈输出清空即可 #include<cstdio> #include<st ...
- HDU - 1062
格式错误2遍:没考虑到连续两个空格的情况,遇到空格最后要输出这个空格,因为题目只需要转换单词. 另外,开cin,cout加速要注意读入不能用scanf,printf,puts,getchar这些.ge ...
- hdu 1062(DFS||dijkstra)
昂贵的聘礼 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 44870 Accepted: 13259 Descripti ...
- 简单字符串处理 hdu1062 Text Reverse
虽然这个题目一遍AC,但是心里还是忍不住骂了句shit! 花了一个小时,这个题目已经水到一定程度了,但是我却在反转这个操作上含糊不清,并且还是在采用了辅助数组的情况下,关系的理顺都如此之难. 其实我是 ...
随机推荐
- Flask 教程 第十五章:优化应用结构
本文翻译自The Flask Mega-Tutorial Part XV: A Better Application Structure 这是Flask Mega-Tutorial系列的第十五部分,我 ...
- 记录一下自己搭建springboot+mybatis+druid 多数据源的过程
前言 上次的一个项目(springboot+mybatis+vue),做到后面的时间发现需要用到多数据源.当时没有思路..后来直接用了jdbc来实现.这几天不是很忙,所以决定自己再搭建一次.不多说, ...
- 题解【POJ1651】Multiplication Puzzle
Description The multiplication puzzle is played with a row of cards, each containing a single positi ...
- python的datetime库
datetime 库 简介 获取时间 主要提供程序计时器 基本使用
- ACM的探索之Keen On Evrything But Triangle(我觉得可以很接近啦!!)
#include<bits/stdc++.h> using namespace std; int main() { int n,q,l,r; while(cin>>n>& ...
- UVA 10881 Piotr's Ants(模拟)
题目链接:https://vjudge.net/problem/UVA-10881 其实这道题的关键只有一句话: 当两个蚂蚁因碰撞而掉头的时候,我们完全可以认为是两个点对穿而过. 这时候我们的主要任务 ...
- VS2017编译错误:#error: Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version
VS2017编译错误:#error: Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll ve ...
- 粪发涂墙-java1
相信很多人和笔者一样,经常会做一些数组的初始化工作,也肯定会经常用到集合类.假如我现在要初始化一个String类型的数组,可以很方便的使用如下代码: String [] strs = {"T ...
- Ubuntu16 nginx 配置 Let's Encrypt 免费ssl
每篇一句 Some of us get dipped in flat, some in satin, some in gloss. But every once in a while you find ...
- Ethereum Learning Materials
Home 注:本页为 EthFans 站内文章精选集.鉴于文章的采集范围较广,我们无法保证文章内容没有重复,也不能保证排列的顺序实现了最优的认识路径.我们只能说,这些文章是我们精挑细选后,确认可以长期 ...