zoukankan      html  css  js  c++  java
  • CodeForces

    Did you mean...

    Beroffice text editor has a wide range of features that help working with text. One of the features is an automatic search for typos and suggestions of how to fix them.


    Beroffice works only with small English letters (i.e. with 26 letters from a to z). Beroffice thinks that a word is typed with a typo if there are three or more consonants in a row in the word. The only exception is that if the block of consonants has all letters the same, then this block (even if its length is greater than three) is not considered a typo. Formally, a word is typed with a typo if there is a block of not less that three consonants in a row, and there are at least two different letters in this block.


    For example:


    the following words have typos: "hellno", "hackcerrs" and "backtothefutttture";
    the following words don't have typos: "helllllooooo", "tobeornottobe" and "oooooo".
    When Beroffice editor finds a word with a typo, it inserts as little as possible number of spaces in this word (dividing it into several words) in such a way that each of the resulting words is typed without any typos.


    Implement this feature of Beroffice editor. Consider the following letters as the only vowels: 'a', 'e', 'i', 'o' and 'u'. All the other letters are consonants in this problem.


    Input
    The only line contains a non-empty word consisting of small English letters. The length of the word is between 1 and 3000 letters.


    Output
    Print the given word without any changes if there are no typos.


    If there is at least one typo in the word, insert the minimum number of spaces into the word so that each of the resulting words doesn't have any typos. If there are multiple solutions, print any of them.


    Example
    Input
    hellno
    Output
    hell no 
    Input
    abacaba
    Output
    abacaba 
    Input
    asdfasdf
    Output
    asd fasd f 

    题意:每三个不同的辅音字母不能在一起。三个辅音字母可以是两个相同的。

    思路:输出的时候控制空格的输出。

    #include<stdio.h>
    #include<string>
    #include<map>
    #include<iostream>
    #include<algorithm>
    using namespace std;
    map<char,int>m;
    int b[100000];
    int vis[100000];
    int judge(char a)
    {
        if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u')
            return 1;
        else
            return 0;
    }
    int main()
    {
        string s;
        cin>>s;
        int x=0;
        for(int i=0; i<s.size(); i++)
        {
            if(judge(s[i])==1)
            {
                x=0;
            }
            else
                x++;
            if(x>2&&(s[i]!=s[i-1]||s[i-1]!=s[i-2]))
            {
                cout<<" ";
                x=1;
            }
            cout<<s[i];
        }
        cout<<endl;
    }




  • 相关阅读:
    Http接口安全设计
    RTMP服务器搭建(nginx+rtmp)
    OSI七层协议详解
    TCP协议的3次握手与4次挥手过程【深度详解】
    new和delete的深层次剖析(C++)
    大小端模式详解
    MP4文件格式分析及分割实现(附源码)
    使用HBuilder将H5的项目打包成手机可安装的webapp程序(.apk)
    Centos7 解决odoo10打印条形码显示方框乱码的问题
    linux 中运行Django项目
  • 原文地址:https://www.cnblogs.com/da-mei/p/9053314.html
Copyright © 2011-2022 走看看