编程练习

codeforces 118A (implementation,

2017-03-30  本文已影响0人  codinRay

http://codeforces.com/problemset/problem/118/A

生词:

vowel n.元音

consonant n.辅音

corresponding a.对应的

题面:

把一个字符串中的元音字母删除,辅音字母前加上一个‘.’,大写字母转换为小写字母。

使用头文件<cctype>处理。

// codeforces
// 118A
// implementation, string
#include <iostream>
#include <string>
#include <cctype>
#include <set>
using namespace std;
set<char> vowel{ 'a','e','i','o','u','y' };
int main() {
    string s;
    while (cin >> s) {
        int len = (int)s.length();
        for (auto &i : s) {
            char c = tolower(i);
            if (vowel.count(c))
                continue;
            else
                cout << '.' << c;
        }
        cout << endl;
    }
    return 0;
}
上一篇 下一篇

猜你喜欢

热点阅读