leetcode824
2024-08-27 19:07:28
class Solution {
public:
void SplitString(const string& s, vector<string>& v, const string& c)
{
string::size_type pos1, pos2;
pos2 = s.find(c);
pos1 = ;
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 = ; i < V.size(); i++)
{
string word = V[i];
char begin = word[];
string newword = "";
if (ST.find(begin) != ST.end())//元音
{
newword = word + "ma";
}
else//辅音
{
string a = word.substr();
string b = word.substr(, );
newword = a + b + "ma";
}
for (int j = ; j <= i; j++)
{
newword += "a";
}
Result += newword;
if (i != V.size() - )
{
Result += " ";
}
}
return Result;
}
};
最新文章
- Android GZIP压缩IO流,优化APP数据传输(一)
- Project Euler欧拉计划
- QC学习一:Windows环境中Quality Center 9.0安装详解
- MyBatis入门案例 增删改查
- [ubuntu]deb软件源
- iOS:图片拉伸不变形技巧
- 关于IE8不支持document.getElementById().innerHTML的问题
- Async 与 Await 关键字研究
- ZOJ 3696 Alien&#39;s Organ 概率论 泊松分布
- jQuery与js的length属性
- CSS3 文字与字体相关样式
- table-一列细分为多列(合并单元格)
- Jmeter二次开发
- 字段like多个条件(or关系)简写
- JEECG 新手常见问题大全,入门必读
- MikroTik RouterOS 5.x使用HunterTik 2.3.1进行破解
- SpringBoot的文件下载
- console.dir() 与 console.dirxml() 的使用
- Gson全解析(上)-Gson基础
- Linux 新手入门常用命令
热门文章
- day5-hashlib模块
- 33-THREE.JS 圆柱体
- LeetCode OJ:Longest Palindromic Substring(最长的回文字串)
- react login page demo
- New Concept English three (41)
- 【linux】打包压缩命令
- postgresql recovery.conf改变需要重启吗
- linux中的阻塞机制及等待队列
- [leetcode]_根据二叉树的先序遍历(后序遍历) + 中序遍历 重建二叉树
- 剑指offer-第四章解决面试题的思路(包含min函数的栈)