Skip to content

118A. String Task

implementation/strings, 1000, http://codeforces.com/problemset/problem/118/A

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

去掉元音,并用.来连接剩余字母的小写

python
str = input()
word = str.lower()
output = []
vowel = ['a','e','i','o','u','y']
for char in word:
	if char not in vowel:
		output.append('.')
		output.append(char)
print(''.join(output))

short code

python
print(''.join('.'+l for l in input().lower() if l not in 'aeiouy'))

C++

c++
#include <bits/stdc++.h>
char a[]="aoyeui",c;
int main(){
        while(std::cin>>c)
                if(!strchr(a,c|=32))
                        std::cout<<'.'<<c;
}
Python
import re

s = input()

def process_string(s):
    result = re.sub(r'[aeiouy]', '', s, flags=re.IGNORECASE)#忽略大小写
    result = ''.join('.' + char.lower() for char in result)
    return result

print(process_string(s))

函数中第一行匹配所有元音字母(不区分大小写)并替换为空,第二行在每个剩余字符前添加点号,并转换为小写

思路:正则表达式的反向引用,其中\g<0>引用匹配的全部部分。更精细的反向引用可以用捕获组()和\g<1>这种结构。也可以?P对捕获组命名。

python
import re
s = input().lower()
s = re.sub(r"[aeiouy]", "" ,s)
s = re.sub(r".", "."+r"\g<0>",s)
print(s)