CodeForces - 118A String Task

Posted 海岛Blog

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CodeForces - 118A String Task相关的知识,希望对你有一定的参考价值。

A. String Task
time limit per test2 seconds
memory limit per test256 megabytes

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

问题链接CodeForces - 118A String Task
问题简述:(略)
问题分析:(略)
题记
  这里给出的题解是使用库函数的典范,是工业界的一般做法。
  写个题解容易,写个经典题解难。

AC的C++语言程序如下:

/* CodeForces - 118A String Task */

#include <stdio.h>
#include <ctype.h>
#include <string.h>

const char vowel[] = "aeiouyAEIOUY";

#define N 100
char a[N +1];

int main()

    int i;
    scanf("%s", a);
    for (i = 0; a[i]; i++) 
        if (strchr(vowel, a[i])) continue;
        putchar('.');
        putchar(isupper(a[i]) ? tolower(a[i]) : a[i]);
    

    return 0;

AC的C++语言程序如下:

/* CodeForces - 118A String Task */

#include <stdio.h>
#include <ctype.h>
#include <string.h>

#define N 100
char a[N +1];

int judge(char c)

    return c == 'A' || c == 'a' || c == 'E' || c == 'e' ||
            c == 'I' || c == 'i' || c == 'O' || c == 'o' ||
            c == 'U' || c == 'u' || c == 'Y' || c == 'y';


int main()

    int i;
    scanf("%s", a);
    for (i = 0; a[i]; i++) 
        if (judge(a[i])) continue;
        putchar('.');
        putchar(isupper(a[i]) ? tolower(a[i]) : a[i]);
    

    return 0;

以上是关于CodeForces - 118A String Task的主要内容,如果未能解决你的问题,请参考以下文章

118A

CodeForces - 1003B Binary String Constructing

CodeForces - 779D String Game

CodeForces B. Obtaining the String

Codeforces 797C -Minimal string

CodeForces 624CGraph and String