当前位置:网站首页>824. 山羊拉丁文
824. 山羊拉丁文
2022-04-21 16:51:00 【anieoo】
原题链接:824. 山羊拉丁文
solution:模拟题
class Solution {
public:
string toGoatLatin(string sentence) {
int n = sentence.length();
string res = ""; //定义返回值
for(int i = 0,k = 0;i < n;i++){
int j = i;
while(j < n && sentence[j] != ' ') j++;
k++; //索引+1
if(tolower(sentence[i]) == 'a' || tolower(sentence[i]) == 'e' || tolower(sentence[i]) == 'i' || tolower(sentence[i]) == 'o' || tolower(sentence[i]) == 'u'){
res += sentence.substr(i, j - i);
res += "ma";
for(int i = 0;i < k;i++)
res += "a";
if(j != n) res += " ";
}
else{
res += sentence.substr(i + 1,j - i - 1);
res += sentence[i];
res += "ma";
for(int i = 0;i < k;i++)
res += "a";
if(j != n) res += " ";
}
i = j;
}
return res;
}
};
版权声明
本文为[anieoo]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_42174306/article/details/124313886
边栏推荐
- 手把手教你基于LXD用OAK-D和ROS noetic做ORB SLAM3
- Which exchange is rapeseed meal futures listed on? How is it safest for a novice to open a futures account?
- 解读论文记录 指出经典的RMS证明过程小错误的一个论文的解读
- 下载 Chrome插件 crx的教程
- Ctrip master XSS vulnerability
- JS milliseconds to days, minutes and seconds
- Vitis HLS 构建项目并生成IP核(Vivado HLS)
- 2022 number two real problem
- What kind of earphone doesn't hurt your ears? Bone conduction earphone for non ear wearing
- 怡宝IPO,农夫山泉慌了?
猜你喜欢

Summary of Wu Enda's course of machine learning (4)

Design and practice of unified security authentication for microservice architecture

控制台显示VM+数字+要调试的文件名

高数 | 【多元函数微分学】如何判断二元微分式是否为全微分

.NET宝藏API之:IHostedService,后台任务执行

What kind of earphone doesn't hurt your ears? Bone conduction earphone for non ear wearing

4.25解锁OpenHarmony技术日!年度盛会,即将揭幕!

Apache security configuration

Want to make a fortune by "leaking data"? What a punishment

Apache安全配置
随机推荐
优炫数据库中标北京市应急管理部消防产品合格评定中心项目
拓荆科技登陆科创板:募资约23亿元,总市值突破100亿元
2018-8-10-win10-uwp- exit the program
C language program environment, compilation + link
Multi core and multi CPU programming -- task scheduling
What role can NPU in mobile phone play
直播带货、送外卖、做货运,航空公司靠副业“回血”
机器学习吴恩达课程总结(一)
程序设计天梯赛L2-007 家庭房产(太逆天了,做题老看题解导致忘了这题并查集怎么写了,直接建图dfs做的,麻烦的一)
JS milliseconds to days, minutes and seconds
巴比特副总裁马千里:元宇宙时代NPC崛起,数字身份协议或成为入口级产品丨2022元宇宙云峰会
golang 二进制分析与逆向
Roaming browser local cross site scripting vulnerability
手把手教你基于LXD用OAK-D和ROS noetic做ORB SLAM3
解读论文记录 指出经典的RMS证明过程小错误的一个论文的解读
elmentUI下拉框实现全部功能
机器学习吴恩达课程总结(四)
Haotian Xuhui signed a contract with Changyang technology to jointly build a new ecosystem of industrial Internet security
力扣55. 跳跃游戏
Pfsense和Snorby