zoukankan      html  css  js  c++  java
  • leetcode824

    class Solution {
    public:
        void SplitString(const string& s, vector<string>& v, const string& c)
        {
            string::size_type pos1, pos2;
            pos2 = s.find(c);
            pos1 = 0;
            while (string::npos != pos2)
            {
                v.push_back(s.substr(pos1, pos2 - pos1));
    
                pos1 = pos2 + c.size();
                pos2 = s.find(c, pos1);
            }
            if (pos1 != s.length())
                v.push_back(s.substr(pos1));
        }
        string toGoatLatin(string S) {
            vector<string> V;
            SplitString(S, V, " ");
            set<char> ST;
            ST.insert('a'); ST.insert('e'); ST.insert('i'); ST.insert('o'); ST.insert('u');
            ST.insert('A'); ST.insert('E'); ST.insert('I'); ST.insert('O'); ST.insert('U');
            string Result = "";
            for (int i = 0; i < V.size(); i++)
            {
                string word = V[i];
                char begin = word[0];
                string newword = "";
                if (ST.find(begin) != ST.end())//元音
                {
                    newword = word + "ma";                
                }
                else//辅音
                {
                    string a = word.substr(1);                
                    string b = word.substr(0, 1);                
                    newword = a + b + "ma";                
                }
                for (int j = 0; j <= i; j++)
                {
                    newword += "a";
                }
                Result += newword;
                if (i != V.size() - 1)
                {
                    Result += " ";
                }
            }
            return Result;
        }
    };
  • 相关阅读:
    Docker学习(一)
    mysql定时任务
    如何查看电脑是几核的?
    卸载Mysql connect 6.9.9
    找不到该项目怎么删除
    jmeter录制app脚本
    postman使用
    排查linux系统是否被入侵
    部署apache-tomcat环境
    sudo初级授权设置
  • 原文地址:https://www.cnblogs.com/asenyang/p/9723121.html
Copyright © 2011-2022 走看看