zoukankan      html  css  js  c++  java
  • 元音字符识别复制

    将一个字符串的元音字母复制到另一个字符串,并排序(30分)

    问题描述:

    有一字符串,里面可能包含英文字母(大写、小写)、数字、特殊字符,现在需要实现一函数,将此字符串中的元音字母挑选出来,存入另一个字符串中,并对字符串中的字母进行从小到大的排序(小写的元音字母在前,大写的元音字母在后,依次有序)。

    说明:

    1、  元音字母是a,e,i,o,u,A,E,I,O,U。

    2、  筛选出来的元音字母,不需要剔重(chong);

    最终输出的字符串,小写元音字母排在前面,大写元音字母排在后面,依次有序。

     

    要求实现函数:

    void sortVowel (char* input, char* output);

    【输入】  char* input,表示输入的字符串

    【输出】  char* output,排好序之后的元音字符串。

    【返回】  无

     

    示例

    输入:char *input = “Abort!May Be Some Errors In Out System. “

    输出:char *output =“aeeeooouAEIO “

     1 #include<stdio.h>
     2 void sortVowel (char* input, char* output)
     3 {
     4     int c[256];
     5     int i;
     6     const char *p = input;
     7     for (i=0; i < 256; i++)
     8         c[i] = 0;
     9     while (*p != '')
    10     {
    11         c[*p]++;
    12         p++;
    13     }
    14     i = 0;
    15     while (c['a'] > 0)
    16     {
    17         output[i++] = 'a';
    18         c['a']--;
    19     }
    20     while (c['e'] > 0)
    21     {
    22         output[i++] = 'e';
    23         c['e']--;
    24     }
    25     while (c['i'] > 0)
    26     {
    27         output[i++] = 'i';
    28         c['i']--;
    29     }
    30     while (c['o'] > 0)
    31     {
    32         output[i++] = 'o';
    33         c['o']--;
    34     }
    35     while (c['u'] > 0)
    36     {
    37         output[i++] = 'u';
    38         c['u']--;
    39     }
    40     while (c['A'] > 0)
    41     {
    42         output[i++] = 'A';
    43         c['A']--;
    44     }
    45     while (c['E'] > 0)
    46     {
    47         output[i++] = 'E';
    48         c['E']--;
    49     }
    50     while (c['I'] > 0)
    51     {
    52         output[i++] = 'I';
    53         c['I']--;
    54     }
    55     while (c['O'] > 0)
    56     {
    57         output[i++] = 'O';
    58         c['O']--;
    59     }
    60     while (c['U'] > 0)
    61     {
    62         output[i++] = 'U';
    63     }
    64     output[i] = '';
    65 }
    66 int main()
    67 {
    68     char in[30],out[30];
    69     gets(in);
    70     sortVowel(in,out);
    71     printf("%s
    ",out);
    72 }

  • 相关阅读:
    python-----删除文件到回收站
    python-----列表生成式和列表生成器表达
    html5 标准文档结构
    java基础之 类型转换
    java基础之 数据类型
    java基础之 变量
    java基础之 开发环境配置
    通用登录界面1.1
    mysql获取字段信息
    喵喵喵?
  • 原文地址:https://www.cnblogs.com/george-cw/p/3942362.html
Copyright © 2011-2022 走看看