zoukankan      html  css  js  c++  java
  • 华农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();
           }
       }
    }
    
    
    
  • 相关阅读:
    【大数据云原生系列】大数据系统云原生渐进式演进最佳实践
    Apache Flink on K8s:四种运行模式,我该选择哪种?
    Istio 运维实战系列(2):让人头大的『无头服务』-上
    istio 常见的 10 个异常
    Prometheus Metrics 设计的最佳实践和应用实例,看这篇够了!
    腾讯会议大规模使用Kubernetes的技术实践
    腾讯云推出云原生etcd服务
    Regionals 2014 Asia
    HDU1754 I Hate It splay
    HNOI2002 营业额统计 splay
  • 原文地址:https://www.cnblogs.com/Roni-i/p/8996556.html
Copyright © 2011-2022 走看看