当前位置:网站首页>每日一题-LeetCode824-山羊拉丁文-模拟
每日一题-LeetCode824-山羊拉丁文-模拟
2022-04-21 22:08:00 【李烦烦搞快点】
硬模拟过程就行了 代码如下:
class Solution {
public:
string toGoatLatin(string sentence) {
string ans;
for(int i = 0, p = 0; i < sentence.size(); i ++){
string word = "";
while(i < sentence.size() && sentence[i] != ' ')
word += sentence[i ++];
p ++;
char c = word[0];
if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U')
word += "ma";
else{
for(int j = 1; j < word.size(); j ++)
word[j - 1] = word[j];
word[word.size() - 1] = c;
word += "ma";
}
for(int k = 0; k < p; k ++)
word += 'a';
word += ' ';
ans += word;
}
ans.pop_back();
return ans;
}
};
版权声明
本文为[李烦烦搞快点]所创,转载请带上原文链接,感谢
https://blog.csdn.net/Mr_Ghost812/article/details/124331058
边栏推荐
- 在線CSV轉YAML工具
- Outsourcing student management system architecture design document
- 外包学生管理系统架构设计文档
- 【ES6】函数的扩展
- Oracle查询执行计划
- Download and install the vscade plug-in package offline
- Games101 lec6 anti aliasing and depth buffer
- 因为疫情让服装行业彻底认识到了数字化转型的必要性。
- [ES6] let and const commands
- Eventbridge integrated cloud service practice
猜你喜欢

ROS robot from starting point to end point (IV) reproduction of blue bridge cloud practice

繁凡的对抗攻击论文精读(二)CVPR 2021 元学习训练模拟器进行超高效黑盒攻击(清华)

echart 写一个大屏展示圆边渐变柱状图

Download and install the vscade plug-in package offline

php如何给数组增加一个数组元素

EventBridge 集成云服务实践

what? Your company has not set the JVM initial and maximum heap memory size to the same value?

JVM自定义类加载器在代码扩展性的实践

Thread safety for the first time. This article is enough
![[basic problems of function implementation C language]](/img/73/a400b286819f37a353cc6229e483fe.jpg)
[basic problems of function implementation C language]
随机推荐
Online CSV to yaml tool
【Canvas】基础绘制与使用
[MySQL] solve the problem of MAC accessing MySQL server on windows
[ES6] let and const commands
【ES6】Generator
怎么用vbs实现微信自动发送消息功能
Eventbridge integrated cloud service practice
Push to origin / Master was rejected: error reporting solution
解放双手,推荐一款阿里开源的低代码工具,YYDS~
基于Redis实现分布式锁的7种方案
A thorough understanding -- > shell script
jupyter-notebook没有运行按钮
【ES6】变量的解构赋值
EventBridge 集成云服务实践
INT 102_ TTL 09
记录 splite3 库的一个坑(表名和字段定义不能用占位符?)
Smart Chemical Park solutions
Interview must brush algorithm top101 knapsack nine lectures top14
Outil CSV - YAML en ligne
【ES6】字符串的扩展
