codeforces 118A (implementation, string)

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;
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容