ACM第一期第一题

ACM第一期第一题

题目描述

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.

题解:
先把所有的字母都换成小写的,然后再判断是不是元音。

#include<iostream>
using namespace std;
int  main()     
{
	char ch[101];
	cin >> ch;
	for (int i = 0; i < 101; i++)
	{
		if (ch[i] >= 'A'&&ch[i] <= 'Z')
		{
			ch[i] += 32;
		}                //全部换成小写
		if (ch[i] >= 'a'&&ch[i] <= 'z')
		{
			if (ch[i] != 'a' && ch[i] != 'e' && ch[i] != 'i' && ch[i] != 'o' && ch[i] != 'u' && ch[i] != 'y')
			{
				cout << "." << ch[i];
			}
		}
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_43602944/article/details/84869038