统计字符串中元音字母的个数 C语言编程,统计字符串中各元音字母(即A,E,I,O,U)的个数。...

下列给定函数中,函数fun的功能是:统计字符串中各元音字母(即A,E,I,O,U)的个数。注意:字母不分大小写。例如,输入THIs is a boot,则应输出是1 0 2 2 0。

请改正程序中的错误,使它能得出正确的结果。

注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。

试题程序:

#include

#include

#include

/*************found**************/

fun(char *s, int num[5])

{ int k, i=5;

for(k=0;k

/*************found**************/

num[i]=0;

for(;*s;s++)

{ i=-1;

/*************found**************/

switch(s)

{ case 'a': case'A':{i=0;break;}

case 'e ': case 'E':{i=1;break;}

case 'i': case 'I':{i=2;break;}

case 'o': case 'O':{i=3;break;}

case 'u': case 'U':{i=4;break;}

}

if(i>=0)

num[i]++;

}

}

void main()

{ char s1[81]; int num1[5], i;

system("CLS");

printf("\nPlease enter a string: ");

gets(s1);

fun(s1, num1);

for(i=0;i<5;i++) printf("%d ",num1[i]);

printf("\n");

}

(1)错误:fun(char *s, int num[5])

(2)错误:num[i]=0;

(3)错误:switch(s) 正确:void fun(char *s, int num[5]) 正确:num[k]=0; 正确:switch(*s)

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值