Problem Description
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.
Input
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.
Output
Print the resulting string. It is guaranteed that this string is not empty.
Example
Input |
---|
tour |
Output |
.t.r |
Input |
Codeforces |
Output |
.c.d.f.r.c.s |
Input |
aBAcAba |
Output |
.b.c.b |
问题链接:String Task
问题简述:彼佳开始参加编程课程。在第一课,他的任务是编写一个简单的程序。该程序应该执行以下操作:在给定的字符串中,如果包含大写和小写拉丁字母,则:
删除所有元音,
插入一个字符“.”在每个辅音之前,
将所有大写辅音替换为相应的小写辅音。
元音是字母“A”,“O”,“Y”,“E”,“U”,“I”,其余是辅音。程序的输入正好是一个字符串,它应该将输出作为单个字符串返回,这是在程序处理初始字符串之后产生的。
帮助Petya应对这项简单的任务。
输入
第一行代表Petya程序的输入字符串。此字符串仅由大写和小写拉丁字母组成,其长度为1到100(包括1和100)。
产量
打印生成的字符串。保证此字符串不为空。
问题分析:
此程序可以先把所有字母变成小写,然后将不是a,e,i,o,u,y的字母存入a[j]中,然后控制输出,先输出“.”再输出一个字母a[j]。
C++程序如下:
#include <iostream>
#include<cstring>
using namespace std;
void main()
{
char *a = new char[100]; int i, j = 0, s = 0;
cin >> a;
int l = strlen(a);
for (i = 0; i < l; i++)
{
if(a[i]>='A'&&a[i]<='Z')
{
a[i] += 32;
}
if (a[i] != 'a' &&a[i] != 'o' && a[i] != 'y' && a[i] != 'e' && a[i] != 'u' && a[i] != 'i')
{
a[j++] = a[i];
s++;
}
}
for (j = 0; j < s; j++)
{
cout << "." << a[j];
}
}