VJ第一题Virtual Judge String Task

VJ第一题Virtual Judge String Task

CodeForces - 118A
Time limit
2000 ms
Memory limit
262144 kB
Source
Codeforces Beta Round #89 (Div. 2)
Tags
implementation strings *1100

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.

Input

tour

Output

.t.r

Input

Codeforces

Output

.c.d.f.r.c.s

Input

aBAcAba

Output

.b.c.b

问题注意点:
1.要删除元音字母;
2.每个字母前面加一个;
3.用小写字母换大写;
4.只需要输入一次;

问题解决思路:
1.用string头文件可以比较简洁地解决字符串问题;
2.先把字母大小写切换,删除的时候条件就更加简洁;
3.删除函数s.erase();
4.注意每次删除之后的字符长度会发生变化;
5.输出每个字母之前输出一个“.”就行;

#include<iostream>
#include<string>
using namespace std;

int main()
{
	string a[1];
	cin >> a[0];
	int e = a[0].size();
	for (int i = 0; i < e; i++)
	{
		if (a[0][i]>=65 && a[0][i]<=90)
		{
			a[0][i] = a[0][i] + 32;
		}
		if (a[0][i] == 97 || a[0][i] == 101 || a[0][i] == 105 || a[0][i] == 111 || a[0][i] == 117 || a[0][i]==121)
		{
			a[0].erase(i, 1);
			e = a[0].size();
			i--;
		}
	}
	e = a[0].size();
	for (int i = 0; i < e; i++)
	{
		cout << ".";
		cout << a[0][i];
	}
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_26558047/article/details/84844038