Petya started to attend programming lessons. On the first lesson his task was to write a simple program. The program was supposed to do the following: in the given string, consisting if uppercase and lowercase Latin letters, it:
- deletes all the vowels,
- inserts a character "." before each consonant,
- replaces all uppercase consonants with corresponding lowercase ones.
Vowels are letters "A", "O", "Y", "E", "U", "I", and the rest are consonants. The program's input is exactly one string, it should return the output as a single string, resulting after the program's processing the initial string.
Help Petya cope with this easy task.
The first line represents input string of Petya's program. This string only consists of uppercase and lowercase Latin letters and its length is from 1 to 100, inclusive.
Print the resulting string. It is guaranteed that this string is not empty.
tour
.t.r
Codeforces
.c.d.f.r.c.s
aBAcAba
.b.c.b
/*30ms,0KB*/
#include<cstdio>
#include<cstring>
char str[101];
int main()
{
scanf("%s", str);
int len = strlen(str);
for (int i = 0; i < len; ++i)
{
if (str[i] < 'a')
str[i] += 32;
if (str[i] != 'a' && str[i] != 'e' && str[i] != 'i' && str[i] != 'o' && str[i] != 'u' && str[i] != 'y')
printf(".%c", str[i]);
}
return 0;
}
或者:
/*30ms,0KB*/
#include<cstdio>
#include<cstring>
#include<cctype>
char str[101];
int main()
{
scanf("%s", str);
int len = strlen(str);
for (int i = 0; i < len; ++i)
{
str[i] = tolower(str[i]);
if (str[i] != 'a' && str[i] != 'e' && str[i] != 'i' && str[i] != 'o' && str[i] != 'u' && str[i] != 'y')
printf(".%c", str[i]);
}
return 0;
}
CodeForces A.StringTask 解析

本文介绍了一个简单的编程任务——CodeForces A.StringTask,任务要求删除字符串中的所有元音字母,将大写辅音字母转换为小写,并在每个辅音前插入一个点号。文章提供了两段实现这一功能的C++代码示例。
568

被折叠的 条评论
为什么被折叠?



