当前位置:网站首页>7-2 h0107. Pig-Latin
7-2 h0107. Pig-Latin
2022-06-11 17:17:00 【西红柿_码农】
您已经确定 PGP 加密对于您的电子邮件来说不够强大。您已决定先将明文字母转换为 Pig Latin,然后再使用 PGP 加密来补充它。
输入格式:
您将编写一个程序,该程序将接收任意数量的文本行并以 Pig Latin 输出。每行文本将包含一个或多个单词。“单词”被定义为连续的字母序列(大写和/或小写)。单词应根据以下规则转换为 Pig Latin(非单词应与输入中出现的完全相同):
以元音开头的单词(a、e、i、o或u,以及它们的大写版本)应该只附加字符串 `` ay ''(不包括引号)。例如,“ apple ”变成了“ appleay ”。
以辅音开头的单词(除A、a、E、e、I、i、O、o、U或u以外的任何字母)应删除第一个辅音并将其附加到单词的末尾,然后附加
ay''也是。例如,hello''变成`` ellohay ''。不要更改任何字母的大小写。
输出格式:
对每一组输入,在一行中以 Pig Latin 输出。
输入样例:
This is the input.
输出样例:
hisTay isay hetay inputay.#include<stdio.h>
int isletter(char a)
{
if (a >= 65 && a <= 90)
return 1;
else if (a >= 97 && a <= 122)
return 1;
return 0;
}
int isvowel(char c)
{
if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U')
{
return 1;
}
return 0;
}
char b[1024], t;
int main()
{
char a;
int i;
while (scanf("%c", &a)!=EOF)
{
if (isletter(a) == 1)
{
b[t++] = a;
}
else
{
if (t == 0) {
printf("%c", a);
continue;
}
if (isvowel(b[0]) == 1) {
for (i = 0; i < t; ++i) {
printf("%c", b[i]);
}
printf("ay%c", a);
}
else {
for (i = 1; i < t; ++i) {
printf("%c", b[i]);
}
printf("%cay%c", b[0], a);
}
t = 0;
}
}
return 0;
}
边栏推荐
- Katalon Studio Enterprise
- Song of the sea in 5g Era
- 搜狐全员遭诈骗,暴露哪些问题?
- LeetCode-384. Scramble array
- which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mod
- What products are good for cross-border e-commerce? What are the top selling categories?
- 活动 | Authing 首次渠道合作活动圆满落幕
- Axi protocol Basics
- 04_特征工程—特征选择
- 论文阅读 dyngraph2vec: Capturing Network Dynamics using Dynamic Graph Representation Learning
猜你喜欢

Custom or subscription? What is the future development trend of China's SaaS industry?
![[Clickhouse column] create a new library, user and role](/img/e5/d11493a37e25b7dde6cc43b3828749.png)
[Clickhouse column] create a new library, user and role

04_特征工程—特征选择

端口规划与APJ

用实际案例分析PMP与ACP应该考哪个?哪个更有用?

Read and understand the development plan for software and information technology service industry during the "14th five year plan"

Vscode configures eslint to automatically format an error "auto fix is enabled by default. use the single string form“

Derivation of child numbering formula for nodes numbered I in full k-ary tree

【Mysql】redo log,undo log 和binlog详解(四)

From manufacturing to "intelligent manufacturing", explore the way for manufacturing enterprises to break the situation
随机推荐
Export data prompt -- solution to the problem of secure file priv option
信息安全数学基础 Chapter 1——整除
为什么udp流设置1316字节
Go get downloaded package path
Xie Yang, CEO of authing, was selected into Forbes' 30 under 30 Asia list in 2021
From a "trendsetter" to a "wind chaser", can master Kang still lead the market?
【线上问题】Timeout waiting for connection from pool 问题排查
Derivation of child numbering formula for nodes numbered I in full k-ary tree
【Mysql】redo log,undo log 和binlog详解(四)
使用exe4j 将.jar文件打包为.exe文件
自动化测试-Selenium
活动 | Authing 首次渠道合作活动圆满落幕
[Clickhouse column] create a new library, user and role
TypeScipt基础
Config: user attribute configuration framework
The use of histogram function in MATLAB
Solr (II) Solr adds core and dependent package path
LeetCode-384. Scramble array
Authing CEO 谢扬入选福布斯 2021 年 30 Under 30 亚洲榜单
从制造到“智造”,探索制造企业破局之道