“玲珑杯”线上赛 Round #15 河南专场 F -- 咸鱼文章

Start Time:2017-05-30 12:00:00 End Time:2017-05-30 17:00:00 Refresh Time:2017-06-02 09:12:55 Public

F -- 咸鱼文章

Time Limit:1s Memory Limit:128MByte

Submissions:440Solved:178


DESCRIPTION

elttiL moT nwod eht teerts sllac ruo god " ehT peek god " . piZ si a peehs god . tuB nehw moT seirt ot yas " peeS " , ti semoc tuo " peek " . dnA ni a yaw moT si thgir . piZ si syawla gnignirb sgniht oh rof su ot peek ! ll'I llet uoy tuoba emos fo meht .
s'piZ tsrif tneserp saw a eohs . tI saw edam fo neerg klis .
eW t'ndid wonk woh piZ dnuof eht eohs . tuB retfa a tnemom yraM , ym gib retsis , dlot em eht eohs dah a egnarts llems . I deddon dna dleh ym eson . " tahW od uoy kniht ti si ? "
" tI sllems ekil gnihtemos rof gninaelc . I kniht enoemos deirt ot naelc a tops ffo eht eohs . nehT eh tup ti ta eht rood ot yrd . "
" gnolA emac piZ . dnA eyb-doog eohs ! " I dias . " eW dluohs ekat ti kcab . "
" eW t'nac " . dias ym rettsis .
" ebyaM elttil moT si thgir , " yraM dias . " ebyaM piZ si a peek god ! "

你正在做英语阅读,可哪知这是一篇咸鱼文章,整个文章的所有单词都是翻转的,你很慌。

不过你是咸鱼程序员,你可以写代码将这篇文章翻转回来,那么翻转回来吧。

INPUT
输入一篇英文文章。输入数据中只包含空格、换行符和小写大写字母。满足总字数小于等于100000
OUTPUT
你应该把这个文章的所有单词都翻转回来,输出即可。
SAMPLE INPUT
AAA BBBAB AB
SAMPLE OUTPUT
AAA BBBBA BA
SOLUTION
解题思路:看到这道题瞬间想到了河南第九届省赛的第一题,采用相同的解法。(当时因为比赛时最后没有输出一个换行,wa了五次:)
我的代码:
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<memory.h>
#include<string>
#include<algorithm>
using namespace std;
int place(char ch)
{
    if(ch>='a'&&ch<='z'||ch>='A'&&ch<='Z')
        return 1;
    else
        return 0;
}
int main()
{
    char ch;
    string s="";
    string a[100001];
    int k=0;
    while(scanf("%c",&ch)!=EOF)
    {
         if(place(ch)==0)
         {
             string ss="";
             for(int i=s.size()-1;i>=0;i--)
                ss+=s[i];
            s="";
            a[k++]=ss;
            if(s=="")
                a[k++]=ch;
         }
         else
            s+=ch;
    }
    for(int i=0;i<k-1;i++)
        cout<<a[i];
    cout<<endl;
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值