我是靠谱客的博主 善良高跟鞋,最近开发中收集的这篇文章主要介绍第一题,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

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.
问题简述:输入一串字符,输出辅音字母,大写换小写,输出辅音字母之前加“.”
程序说明:检查输入字符,如果是元音字母,不记录,如果是辅音字母,判断大小写,小写直接记录,大写的话转化小写再记录,最后加“."输出
AC代码
#include
using namespace std;
int main()
{
char a[101], b[210];
cin >> a;
int i = 0, i2 = 0;
for(;i<strlen(a);i++)
{
if (a[i] != ‘a’&&a[i] != ‘A’&&a[i] != ‘e’&&a[i] != ‘E’&&a[i] != ‘i’&&a[i] != ‘I’&&a[i] != ‘o’&&a[i] != ‘O’&&a[i] != ‘u’&&a[i] != ‘U’&&a[i] != ‘y’&&a[i] != ‘Y’)
{
if (a[i] >= ‘B’&&a[i] <= ‘Z’)
{
a[i] = a[i] + 32;
}
b[i2] = ‘.’;
b[i2 + 1] = a[i];
i2 += 2;
}
}
b[i2] = 0;
cout << b;
}

最后

以上就是善良高跟鞋为你收集整理的第一题的全部内容,希望文章能够帮你解决第一题所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(37)

评论列表共有 0 条评论

立即
投稿
返回
顶部