zoukankan      html  css  js  c++  java
  • 挑元字符

    这是今年我的一位实习朋友面试华为的一道题:

    题目如下:

    描述:在字符串中,挑出以下元音字符并按顺序输出,字符串长度不超过50,需挑出的字符为a,e,i,o,u以及它们的大写。

    时间限制:无

    内存限制:无

    输出:

      第一行,元音字母的种类,元音字母的的长度,其他字母的长度,它们之间用一个英文空格隔开。

      第二行,按顺序输出元音字母,保持顺序大小写

    样例输入:

      I love China

    输出:

      5 5 7

      Ioeia

    代码实现:

      python:

        

    str_input = raw_input()
    result_str = ''
    lenth = len(str_input)
    for i in range(0,lenth):
        if str_input[i] in ['a','e','i','o','u','A','E','I','O','U']:
            result_str = result_str + str_input[i]
    lenth_type = len(set(result_str))
    lenth_str = len(result_str)
    lenth_other = lenth - lenth_str
    result_num = str(lenth_type) + " " + str(lenth_str) + " " + str(lenth_other)
    print result_num
    print result_str
  • 相关阅读:
    UVa532 Dungeon Master 三维迷宫
    6.4.2 走迷宫
    UVA 439 Knight Moves
    UVa784 Maze Exploration
    UVa657 The die is cast
    UVa572 Oil Deposits DFS求连通块
    UVa10562 Undraw the Trees
    UVa839 Not so Mobile
    327
    UVa699 The Falling Leaves
  • 原文地址:https://www.cnblogs.com/codeblock/p/5956966.html
Copyright © 2011-2022 走看看