1

作者: OorangeZ | 来源:发表于2018-12-07 16:55 被阅读0次

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.
问题链接:https://vjudge.net/problem/CodeForces-118A
问题简述:输入包含1-100的一串字母,包含大写字母跟小写字母,删除所有元音字母,在所有辅音字母前面加个.,把所有的大写辅音字母用相应的小写字母替代,程序输出是一个字符串,输出单个的字符串,在程序处理最初的字符串后产生
问题分析:用char数组将输入的字母字符串存储,用循环语句中的switch语句逐个判断字母是否为元音字母,如果是则把数组中的元音字符后的元素全部向前移动一位(相当于删除),再判断是否为大写辅音,如是则用小写字母的ascill码值替换,最后建立一个201存储容量大小的char数组,每将一个原本数组中的元素添加进新数组前加一个.即可
AC通过的C++语言程序如下:

#include <iostream>
using namespace std;
int main()
{
    static char st[101];
    cin >> st;
    int n = 0;
    while (st[n] != '\0')
    {
            switch (st[n])
            {
            case 65:case 69:case 73:case 79:case 85:case 89:case 97: case 101:case 105: case 111:case 117:case 121:
                {
                     int e = n;
                     while (st[e] != '\0')
                     {
                         st[e] = st[e + 1];
                         e++;
                     }
                     break;
                }
                 default:
                {
                     if (st[n] <= 90)
                     {
                         st[n] = st[n] + 32;
                     }
                     n++;
                     break;
                }
            }
    }
    char nw[201] = {'\0'};
    int k = 0, j = 0;
    while (st[k] != '\0')
    {
        nw[j] = 46;
        nw[j + 1] = st[k];
        k++;
        j = j + 2;
        
    }
    cout << nw;
}

相关文章

  • 1▪1▪1▪1▪1

    今天是国际劳动节,出门看人头,上路遇堵车,处处挤破头,急哭也停不下车。 不如歇了吧 ...

  • 1+1+1…+1=1

    对“一”的理解: 赠人玫瑰,不仅仅是手留余香。 利益他人,实际上也疗愈了自己。 利他、利己,如此往复循环, 最终利...

  • (-1)×(-1)= 1

    数学家经过很长一段时间才认识到(-1)×(-1)= 1是不能被证明的(即使大数学家欧拉曾给出不能令人信服的...

  • 1-2-1-1-1

    【下马请罪】 子龙下马,向张飞跪地请罪道:“张将军,一时失手……”话未停,便被张飞一矛刺了个透心凉。子龙堵着胸口汩...

  • 1 1:1 1(原创小说)

    闪回:那天她…… 当时,我确实听到了那个声音,可如今却怎么也记不清了。 掉下来了。 我觉得,那一刻...

  • 《1+1=1-1》

    十一月十一日晚,致X小姐。 十月初九, 一个人购物的孤独, 你谈起, 月光下轧过的马路, 金钱带不来满足, 忙忙碌...

  • 1+1=-1

    结婚育子这几年,在磕磕碰碰中一路走来,才恍然大悟,自己真正的成长,始于育儿。 婚前是父母的公主,虽说家境贫困,却得...

  • 1+1<1

    也许有人看到我的标题就会来质疑我,说我怎么连最简单的数学都不会。1+1=2>1啊,这么简单的算数题,我怎会不知?但...

  • 1+1=-1

    看到他人发表文章,我也有点手痒痒了~这是接着上回文章的下半部分,有点长,没人看到就好了︿︿ 这个第二件小事的主题就...

  • 1⃣️0⃣️1⃣️1⃣️

    昨晚下了雨,早上雾蒙蒙。如画的烟雨曲江我们无暇欣赏,今天小伙伴都去了商场收资源,所以比较集中,真正起到了轰炸效果,...

网友评论

      本文标题:1

      本文链接:https://www.haomeiwen.com/subject/ugtxhqtx.html