zoukankan      html  css  js  c++  java
  • 1127

    1127 - 咸鱼文章

    Time Limit:1s Memory Limit:128MByte

    Submissions:488Solved:200

    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 BBB
    AB AB
    SAMPLE OUTPUT
    AAA BBB
    BA BA
     
    注意格式,注意格式,另外就是,别忽略了连续两个或更多都不是字母的情况。
     1 #include<iostream>
     2 #include<cstring>
     3 #include<cstdio>
     4 #define N 100005
     5 using namespace std;
     6 char s[N];
     7 char st[N];
     8 int main(){
     9     char c;
    10     int a=0;
    11     int k=0;
    12     while((c=getchar())!=EOF){
    13         if((c>='A'&&c<='Z')||(c>='a'&&c<='z')){
    14            st[a++]=c;
    15         }else{
    16             if(strlen(st)){
    17                 for(int i=a-1;i>=0;i--){
    18                     s[k++]=st[i];
    19                 }
    20                 s[k++]=c;
    21                 a=0;
    22             }else{
    23                 s[k++]=c;
    24             }
    25         }
    26     }
    27     for(int i=0;i<k;i++){
    28             cout<<s[i];
    29     }
    30     return 0;
    31 }
  • 相关阅读:
    windows下使用mingw编译出ffplay(简化版)
    Linux中查看GNOME版本号
    Linux操作系统入门学习总结(2015.10)
    c++11并发机制
    CentOS 7修改管理员密码
    windows下批量杀死进程
    ffmpeg抓屏输出的设置
    User-Defined-Literal自定义字面量
    GitHub支持的Markdown语法 GitHub Flavored Markdown
    c++11支持类数据成员的初始化
  • 原文地址:https://www.cnblogs.com/zllwxm123/p/7220315.html
Copyright © 2011-2022 走看看