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】的更多相关文章

  1. 华农oj Problem K: 负2进制【有技巧构造/待补】

    Problem K: 负2进制 Time Limit: 2 Sec Memory Limit: 128 MB Submit: 51 Solved: 6 [Submit][Status][Web Boa ...

  2. 华农oj Problem B: Averyboy找密码【STL】

    Problem B: Averyboy找密码 Time Limit: 1 Sec Memory Limit: 128 MB Submit: 83 Solved: 29 [Submit][Status] ...

  3. 华农oj Problem J: 幻化【贪心/抽屉原理】

    Problem J: 幻化 Time Limit: 2 Sec Memory Limit: 128 MB Submit: 18 Solved: 3 [Submit][Status][Web Board ...

  4. 华农oj 2192: hzk又在打人【CRT合并/待补】

    2192: hzk又在打人 Time Limit: 12 Sec Memory Limit: 512 MB Submit: 52 Solved: 1 [Submit][Status][Web Boar ...

  5. Problem L

    Problem Description 在2×n的一个长方形方格中,用一个1× 2的骨牌铺满方格,输入n ,输出铺放方案的总数. 例如n=3时,为2× 3方格,骨牌的铺放方案有三种,如下图: L&qu ...

  6. 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 ...

  7. 华农js抢课神器

    又到了华农选课的时候,服务器估计就受不了,每天奔溃几次,这次选课贪心了点,竟然选了5门,好吧,我承认我只中了1门,什么??刚刚换课给同学马上就被人抢了?我来告诉你原因吧,最近发现一位大神写了一份js脚 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. 一道关于C++ 继承/虚函数 笔试题 [转]

    转自:http://www.cnblogs.com/yangyh/archive/2011/06/04/2072393.html 首先这位作者, 因为看了这篇简短的一个博文, 我相同了关于虚函数方面的 ...

  2. 剑指Offer - 九度1504 - 把数组排成最小的数

    剑指Offer - 九度1504 - 把数组排成最小的数2014-02-06 00:19 题目描述: 输入一个正整数数组,把数组里所有数字拼接起来排成一个数,打印能拼接出的所有数字中最小的一个.例如输 ...

  3. 剑指Offer - 九度1348 - 数组中的逆序对

    剑指Offer - 九度1348 - 数组中的逆序对2014-01-30 23:19 题目描述: 在数组中的两个数字,如果前面一个数字大于后面的数字,则这两个数字组成一个逆序对.输入一个数组,求出这个 ...

  4. 1004 Counting Leaves (30 分)(树的遍历)

    给出一棵树,问每一层各有多少叶子节点 dfs遍历树 #include<bits/stdc++.h> using namespace std; vector<]; int n,m; i ...

  5. linux socket c/s上传文件

    这是上传文件的一个示例,可以参照自行修改成下载或者其它功能. 在上传时,需要先将文件名传到服务器端,这是采用一个结构体,包含文件名及文件名长度(可以用于校验),防止文件名乱码. client #inc ...

  6. HDU 4714 Tree2cycle 找规律

    假设最少删除的边的个数为cost,显然,最终答案即为cost+cost+1 (因为删除一条边,就会增加一个链,所以删除cost条边后,就会有cost+1条链,将这cost+1条链连接起来的代价为cos ...

  7. ZOJ 3717 Balloon ( TLE )

    正解2-SAT. 我用DLX想搜一搜的,结果TLE了…… 没什么遗憾,最起码我尝试过了. 扔个代码留作纪念. #include <cstdio> #include <cstring& ...

  8. C# 访问修饰符internal的访问范围误区释疑

      一.前言                                               MSDN关于访问修饰符的访问级别解释: 访问修饰符是一些关键字,用于指定声明的成员或类型的可访 ...

  9. 关于tap设备

    $QEMU_PATH \ -nographic \ -drive file=./rootfs.ext4,format=raw \ -net nic,vlan=0 -net tap,vlan=0,ifn ...

  10. [UOJ#348][WC2018]州区划分

    [UOJ#348][WC2018]州区划分 试题描述 小 \(S\) 现在拥有 \(n\) 座城市,第ii座城市的人口为 \(w_i\),城市与城市之间可能有双向道路相连. 现在小 \(S\) 要将这 ...