题目链接: 传送门

Dubstep

Time Limit: 1000MS     Memory Limit: 32768 KB

Description

Vasya works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to take a couple of old songs and make dubstep remixes from them.
Let's assume that a song consists of some number of words. To make the dubstep remix of this song, Vasya inserts a certain number of words "WUB" before the first word of the song (the number may be zero), after the last word (the number may be zero), and between words (at least one between any pair of neighbouring words), and then the boy glues together all the words, including "WUB", in one string and plays the song at the club.
For example, a song with words "I AM X" can transform into a dubstep remix as "WUBWUBIWUBAMWUBWUBX" and cannot transform into "WUBWUBIAMWUBX".
Recently, Petya has heard Vasya's new dubstep track, but since he isn't into modern music, he decided to find out what was the initial song that Vasya remixed. Help Petya restore the original song.

Input

The input consists of a single non-empty string, consisting only of uppercase English letters, the string's length doesn't exceed 200 characters. It is guaranteed that before Vasya remixed the song, no word contained substring "WUB" in it; Vasya didn't change the word order. It is also guaranteed that initially the song had at least one word.

Output

Print the words of the initial song that Vasya used to make a dubsteb remix. Separate the words with a space.

Sample Input

WUBWUBABCWUB
WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB

Sample Output

ABC
WE ARE THE CHAMPIONS MY FRIEND 

思路:

简单字符串处理,删除"WUB"输出剩下的字符。

#include<iostream>
#include<cstdio>
#include<string>
using namespace std;

int main()
{
    string str,tmp;
    cin >> str;
    int len = str.size();
    for (int i = 0;i < len;)
    {
        string s = str.substr(i,3);
        if (s == "WUB")
        {
            i += 3;
        }
        else
        {
            tmp += str[i];
            i++;
            string s = str.substr(i,3);
            if (s == "WUB")
            {
                tmp += ' ';
            }
        }
    }
    if (tmp != "")
        cout << tmp << endl;
    return 0;
} 

CF 208A Dubstep(简单字符串处理)的更多相关文章

  1. 第一部分之简单字符串SDS(第二章)

    一,什么是SDS? 1.引出SDSC字符串:c语言中,用空字符结尾的字符数组表示字符串简单动态字符串(SDS):Redis中,用SDS来表示字符串.在Redis中,包含字符串值的键值对在底层都是由SD ...

  2. hdu 5059 简单字符串处理

    http://acm.hdu.edu.cn/showproblem.php?pid=5059 确定输入的数是否在(a,b)内 简单字符串处理 #include <cstdio> #incl ...

  3. C 封装一个通用链表 和 一个简单字符串开发库

    引言 这里需要分享的是一个 简单字符串库和 链表的基库,代码也许用到特定技巧.有时候回想一下, 如果我读书的时候有人告诉我这些关于C开发的积淀, 那么会走的多直啊.刚参加工作的时候做桌面开发, 服务是 ...

  4. 1442: Neo 的简单字符串(字符串)

    1442: Neo 的简单字符串 时间限制: 10 Sec 内存限制: 128 MB 提交: 9 解决: 3 统计 题目描述 Neo 给你一系列字符串,请你输出字符串中的不同单词个数以及总单词个数. ...

  5. Codeforces 208A:Dubstep(字符串)

    题目链接:http://codeforces.com/problemset/problem/208/A 题意 给出一个字符串,将字符串中的WUB给删去,如果两个字母间有WUB,则这两个字母用空格隔开 ...

  6. Java实验--关于简单字符串回文的递归判断实验

    首先题目要求写的是递归的实验,一开始没注意要求,写了非递归的方法.浪费了一些时间,所谓吃一堑长一智.我学习到了以后看实验的时候要认真看实验中的要求,防止再看错. 以下是对此次的实验进行的分析: 1)递 ...

  7. python 简单字符串字典加密

    1 def crypt(source,key): from itertools import cycle result='' temp=cycle(key) for ch in source: res ...

  8. 洛谷 简单字符串 'P1055ISBN号码' 问题

    题目描述如下: 知识点①:char数组与int型数字进行运算时,需要将 char[i]-'0' .比如 char c[5]; int i; for(i=0;i<5;i++) scanf(&quo ...

  9. c# 进程间的通信实现之一简单字符串收发

       使用Windows API实现两个进程间(含窗体)的通信在Windows下的两个进程之间通信通常有多种实现方式,在.NET中,有如命名管道.消息队列.共享内存等实现方式,这篇文章要讲的是使用Wi ...

随机推荐

  1. LINQ基础概述

    介绍LINQ基础之前,首说一下LINQ 的历史和LINQ是什么,然后说一下学习 LINQ要了解的东西和 LINQ基础语法   LINQ 的历史 从语言方面的进化 –委托 –匿名方法 –Lambda表达 ...

  2. github上最全的资源教程-前端涉及的所有知识体系

    前面分享了前端入门资源汇总,今天分享下前端所有的知识体系. 个人站长对个人综合素质要求还是比较高的,要想打造多拉斯自媒体网站,不花点心血是很难成功的,学习前端是必不可少的一个环节, 当然你不一定要成为 ...

  3. Vue学习笔记-1

    前言 本文不是Vue.js的教程,只是一边看官网Vue的教程文档一边记录并总结学习过程中遇到的一些问题和思考的笔记. 1.vue和avalon一样,都不支持VM初始时不存在的属性 而在Angular里 ...

  4. Java网络编程——IP

    类:InetAdrress 该类主要用于表示互联网协议(IP对象)地址,且无构造方法 主要方法: public static InetAddress getLocalHost()-->返回本地主 ...

  5. Windows平台下安装Hadoop

    今天参照这个网址(http://www.cnblogs.com/kinglau/archive/2013/08/20/3270160.html)安装了下,前面七步没有问题. 到第八步出问题了,后来看了 ...

  6. Thinkphp url 除去index.php

    例如你的原路径是 http://localhost/test/index.php/index/add那么现在的地址是 http://localhost/test/index/add如何去掉index. ...

  7. Java--笔记(5)

    41.面向对象的五大基本原则 (1)单一职责原则(SRP) (2)开放封闭原则(OCP) (3)里氏替换原则(LSP) (4)依赖倒置原则(DIP) (5)接口隔离原则(ISP) 单一职责原则(SRP ...

  8. [转]响应式WEB设计学习(2)—视频能够做成响应式吗

    原文地址:http://www.jb51.net/web/70361.html 上集回顾: 昨天讲了页面如何根据不同的设备尺寸做出响应.主要是利用了@media命令以及尺寸百分比化这两招. 上集补充: ...

  9. 查看本机ip

    视窗+R  然后输入cmd, enter 后再黑色窗口里输入  ipconfig

  10. 去掉iPhone、iPad的默认按钮样式 去掉高光样式:

    input[type="button"], input[type="submit"], input[type="reset"] { -web ...