String Task
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.
Examples
Input
tour
Output
.t.r
Input
Codeforces
Output
.c.d.f.r.c.s
Input
aBAcAba
Output
.b.c.b
问题简述
输入字符串,删除元音字母“A,E,I,O,U,Y",并将大写转换成小写,并在辅音字母前添加一个‘.’。
程序分析
构造一个字符型数组,通过比较每个元素的ASCLL码值,完成问题。需注意比较过程中,因输入的字符串长度不定,因此需要确定所输入字符串长度,推荐可用strlen函数,头文件为#include<string.h>。否则,字符串后的“\0"会干扰结果,导致程序错误。
AC程序如下:
//CodeForces-118A
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
int i, j;
char a[101];
cin>> a;
j = strlen(a);
for (i = 0; i <j; i++)
{
if (a[i] >= 65 && a[i] <= 90)
a[i] = a[i] + 32;
if (a[i] != 65 && a[i] != 97 && a[i] != 69 && a[i] != 101 && a[i] != 73 && a[i] != 105 && a[i] != 79 && a[i] != 111 && a[i] != 85 && a[i] != 117 && a[i] != 89 && a[i] != 121)
cout << '.' << a[i];
}
return 0;
}