华农oj Problem L: CreatorX背英语【STL】
Problem L: CreatorX背英语
Time Limit: 1 Sec Memory Limit: 64 MB
Submit: 53 Solved: 36
[Submit][Status][Web Board]
Description
CreatorX最近在忙着背英语,
Hzk is a young and beautiful and cute boy
但是正常背诵的效果他觉得不好,于是他又想了一个点子,倒着背。
Boy cute and beautiful and young a is Hzk
现在给他给你一个只包含大小写字母和逗号(逗号替代空格)的英文句子,单词被一个逗号隔开,让你跟着一起倒着背出来,
Input
第一行一个数字T代表测试的组数。(T<=20)
对于每组测试一行只由大小写字母和逗号组成字符串s(0<|s|<=2000),保证没有连着的逗号,而且句子的第一个字母和最后一个字母不是逗号.
Output
对于每组测试输出一行,把句子以单词为单位倒着输出.
Sample Input
2
Hzk,is,a,young,and,beautiful,and,cute,boy
abc,def
Sample Output
boy,cute,and,beautiful,and,young,a,is,Hzk
def,abc
HINT
这也要hint吗QaQ
还是要的,输入的时候最好不要用getchar(),由于环境问题可能会出奇奇怪怪的错误。
#include <functional>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <bitset>
#include <set>
#include <vector>
#include <sstream>
using namespace std;
const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const double eps = 1e-15;
typedef long long ll;
typedef pair <int, int> PLL;
vector<string> v;
int main()
{
int t;
cin>>t;
t++;
while(t--)
{
string s,buf;
getline(cin,s);
stack<string> st;
while( !st.empty() )
st.pop();
for(int i=0;i<s.size();i++)
{
if(s[i]==',') s[i]=' ';
}
int k=0;
stringstream ss(s);
while(ss>>buf)
{
st.push(buf);
k++;
}
int f=0;
while(!st.empty())
{
f++;
if(f == k) {
cout<<st.top()<<endl;
}
else
cout<<st.top()<<",";
st.pop();
}
}
}
华农oj Problem L: CreatorX背英语【STL】的更多相关文章
- 华农oj Problem K: 负2进制【有技巧构造/待补】
Problem K: 负2进制 Time Limit: 2 Sec Memory Limit: 128 MB Submit: 51 Solved: 6 [Submit][Status][Web Boa ...
- 华农oj Problem B: Averyboy找密码【STL】
Problem B: Averyboy找密码 Time Limit: 1 Sec Memory Limit: 128 MB Submit: 83 Solved: 29 [Submit][Status] ...
- 华农oj Problem J: 幻化【贪心/抽屉原理】
Problem J: 幻化 Time Limit: 2 Sec Memory Limit: 128 MB Submit: 18 Solved: 3 [Submit][Status][Web Board ...
- 华农oj 2192: hzk又在打人【CRT合并/待补】
2192: hzk又在打人 Time Limit: 12 Sec Memory Limit: 512 MB Submit: 52 Solved: 1 [Submit][Status][Web Boar ...
- Problem L
Problem Description 在2×n的一个长方形方格中,用一个1× 2的骨牌铺满方格,输入n ,输出铺放方案的总数. 例如n=3时,为2× 3方格,骨牌的铺放方案有三种,如下图: L&qu ...
- The Ninth Hunan Collegiate Programming Contest (2013) Problem L
Problem L Last Blood In many programming contests, special prizes are given to teams who solved a pa ...
- 华农js抢课神器
又到了华农选课的时候,服务器估计就受不了,每天奔溃几次,这次选课贪心了点,竟然选了5门,好吧,我承认我只中了1门,什么??刚刚换课给同学马上就被人抢了?我来告诉你原因吧,最近发现一位大神写了一份js脚 ...
- Gym 102056L - Eventual … Journey - [分类讨论][The 2018 ICPC Asia-East Continent Final Problem L]
题目链接:https://codeforces.com/gym/102056/problem/L LCR is really an incredible being. Thinking so, sit ...
- 2013-2014 ACM-ICPC, NEERC, Southern Subregional Contest Problem L. Stock Trading Robot 水题
Problem L. Stock Trading Robot 题目连接: http://www.codeforces.com/gym/100253 Description CyberTrader is ...
随机推荐
- 对setTimeout函数的理解
之前去面试一家公司时,面试官出了一道关于js的setTimeout函数的题目: /* *面试官给的原题目如下: *执行mytest()后,控制台输出内容是_____ *function mytest( ...
- python学习笔记十一:操作mysql
一.安装MySQL-python # yum install -y MySQL-python 二.打开数据库连接 #!/usr/bin/python import MySQLdb conn = MyS ...
- 【Lowest Common Ancestor of a Binary Tree】cpp
题目: Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. Accor ...
- python import模块熟悉方法
python import导入的可用模块很多,新增速度较快,无法一次性全部掌握. 掌握熟悉一种模块的方法是非常有价值的技能. 探究模块可以从python解释器入手,具体流程记录如下: 以os模块为例: ...
- Extjs msgTarget 提示位置
extjs msgTarget 有效值包括: qtip:显示一个浮动的提示消息 title:显示一个浏览器浮动提示消息 under:在字段下面显示一个提示消息,使用under时要注意表单的高度 sid ...
- Application_Start事件中用Timer做一个循环任务
protected void Application_Start(object sender, EventArgs e) { System.Timers.Timer timer = new Syste ...
- BI商业智能培训系列——(二)SSIS入门
简介: SSIS,Microsoft SQL Server Integration Services.Integration意为"整合"."一体化".上篇博客中 ...
- 决策树与随机森林Adaboost算法
一. 决策树 决策树(Decision Tree)及其变种是另一类将输入空间分成不同的区域,每个区域有独立参数的算法.决策树分类算法是一种基于实例的归纳学习方法,它能从给定的无序的训练样本中,提炼出树 ...
- 安装PL/SQL Developer,链接本地64位Oracle
请参考: http://www.cnblogs.com/ymj126/p/3712727.html 或者 http://blog.csdn.net/cselmu9/article/details/80 ...
- poj 3678 Katu Puzzle 2-SAT 建图入门
Description Katu Puzzle is presented as a directed graph G(V, E) with each edge e(a, b) labeled by a ...