当前位置:网站首页>LeetCode 每日一题:824. 山羊拉丁文
LeetCode 每日一题:824. 山羊拉丁文
2022-04-21 11:30:00 【Shirandexiaowo】
824. 山羊拉丁文
简单模拟,强调对函数isalpha和tolower等字符处理函数的运用
// shiran
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, n, a) for (int i = n - 1; i >= a; i--)
#define sz(x) (int)size(x)
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define pb push_back
typedef long long ll;
typedef pair<int, int> PII;
const int mod = 1000000007;
class Solution
{
public:
set<char> S = {
'a', 'e', 'i', 'o', 'u'};
string toGoatLatin(string s)
{
string res, post = "a";
rep(i, 0, sz(s))
{
int j = i;
while (j < sz(s) && isalpha(s[j]))
j++;
if (S.count(tolower(s[i])))
{
res += s.substr(i, j - i) + "ma" + post;
}
else
{
res += s.substr(i + 1, j - i - 1) + s[i] + "ma" + post;
}
post += "a";
i = j;
if (i == sz(s)) continue;
res += " ";
}
return res;
}
};
版权声明
本文为[Shirandexiaowo]所创,转载请带上原文链接,感谢
https://blog.csdn.net/MATLAB2020ab/article/details/124313191
边栏推荐
- ES6新特性(6)之箭头函数/Class类
- Normalized records in pycharm
- 阿里超大规模 Flink 集群运维体系介绍
- Nocalhost for dapr remote debugging
- [二叉数]对称二叉树
- [lighthouse] intranet penetration FRP construction
- js---call,apply,bind
- Pgpool II 4.3 Chinese Manual - introductory tutorial
- Calculate the n-bit sum of integers (C language)
- L2-004 这是二叉搜索树吗? (25 分)
猜你喜欢

UNIX philosophy and high concurrency

阿里超大规模 Flink 集群运维体系介绍

Realize browser multi tab communication

redis面试问题

星汉未来成为FinOps产业推进方阵共建单位

常见工具 nc Wireshark反弹shell
![[interview ordinary people vs Expert Series] understanding of B tree and B + tree](/img/17/a81da0a2e6b0c7cb218879f1a79861.jpg)
[interview ordinary people vs Expert Series] understanding of B tree and B + tree

How does IOT platform realize business configuration center

Xinghan will become the co construction unit of finops industry promotion matrix in the future

Tami dog knowledge | what are the legal procedures for equity transfer?
随机推荐
Simple threading - using threads to run multiple browsers easily
InfoQ settled Express
stm32i2c的解答
文件传输(上传下载)
org. apache. flink. client. deployment. ClusterDeploymentException: Could not deploy Yarn job cluster.
Matlab GUI application - lottery (animation demonstration)
ES6新特性(6)之箭头函数/Class类
New features of ES6 (7): proxy proxy / model module / import / export
redis面试问题
Redis cluster mode
1.精准营销实践阿里云odpscmd精准营销数据处理
Convenience stores are crazy: convenience bee, Rosen and Yijie "fierce battle"
(coordinate dynamic programming) lintcode medium 248 · count the number of numbers smaller than a given integer
Interpretation of tamigou project | 100% equity transfer of Hainan outlets Tourism Development Co., Ltd
UNIX philosophy and high concurrency
sentinelsat包介绍
分享 Map 对象和普通对象的 7 个区别
2. Precision marketing practice Alibaba cloud odpscmd data feature project
File transfer (upload and download)
js---call,apply,bind