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 = ;
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;
}
};
leetcode824的更多相关文章
- [Swift]LeetCode824. 山羊拉丁文 | Goat Latin
A sentence S is given, composed of words separated by spaces. Each word consists of lowercase and up ...
- Leetcode824.Goat Latin山羊拉丁文
给定一个由空格分割单词的句子 S.每个单词只包含大写或小写字母. 我们要将句子转换为 "Goat Latin"(一种类似于 猪拉丁文 - Pig Latin 的虚构语言). 山羊拉 ...
随机推荐
- UI- UIView控件知识点回顾
// 通过一个frame来初始化一个UI控件 - (id)initWithFrame:(CGRect)frame; // YES:能够跟用户进行交互 @property(nonatomic,gett ...
- L142
keep half an eye on something分神留意splash out随意花钱 大肆挥霍half a mind有想做某事go Dutch v. 各自付帐,打平伙chance in a ...
- 序(转) · 为 React 而写 -- 废话比较多, 你也可以说丰满
流形 2 年前 (废话比较多 从今年开始,就一直在规划技术沉淀这事. 在阿里巴巴工作的这些年,前端团队日益壮大,同时聚集了一帮志趣相投的伙伴. 作为团队负责人,一方面是借团队在技术道路上的 ...
- node 一站式 学习 教程
还是比较全面的, 包括了 : monogoDB的安装 使用 , 各种插件, 中间件的介绍, 路由的介绍, 各种数据库框架的介绍, 测试介绍; 掌握后应该可以开发一个中型的程序, 大型程序因为有性能的 ...
- [Scala]Scala学习笔记一 基础
1. 变量 val定义的值实际上是一个常亮,无法改变其内容 scala> val num = 0 num: Int = 0 scala> num = 2 <console>:1 ...
- Nodejs之静态资源处理
前言 着眼于问题 重现问题 indexhtml indexcss serverjs 发现问题 解决问题 serverjs express 核心 server-expressjs indexhtml 总 ...
- 深度学习(六十五)移动端网络MobileNets
- verilog case 语句合并问题
有时候在case语句中会有不同选择执行相同操作的情况,为了简化代码,可以将其合并. 以下解答来自百度知道(由于排版问题,有相应修改): reg [1:0]addr_cnt=2'b11; reg rea ...
- v-if和v-show的区别
v-if 是“真实”的条件渲染,因为它会确保条件块(conditional block)在切换的过程中,完整地销毁(destroy)和重新创建(re-create)条件块内的事件监听器和子组件. v- ...
- Shell 参数(1)
shell 中参数相关: ./a.sh a b c d $# 是传给脚本的参数个数 $0 是脚本本身的名字 $1 是传递给该shell脚本的第一个参数 $2 是传递给该shell脚本的第二个参数 $@ ...