题目内容:
请补充函数proc(),该函数的功能是:分类统计一个字符串中元音字母和其他字符的个数(不区分大小写)。例如,输入imnlaeouOWC,结果为:A:1 E:1 1:2 0:2 U:1 other:4。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#define M 100
void proc(char*str,int bb[])
{
char*p=str;
int i=0:
for(i=0;i<6;i++)
【1】 ;
while(*p)
{
switch(*p)
{
case'A ':
case'a':bb[0]++;break;
case 'E':
case'e ':bb[1]++;break;
case '1':
case'i':bb[2]++;break;
case'0':
case'o':bb[a]++;break;
case 'U':
case'u':bb[4]++;break;
default:【2】;
}
【3】
}
}
void main()
{
char str[M],ss[6]="AEIOU";
int i;
int bb[6];
system("CLS");
printf("Input a string:\n");
gets(str);
printf("the string is:\n");
puts(str);
proc(str,bb);
for(i=0;i<5;i十+)
printf("\n%c:%d",ss[i],bb[i]);
printf("\nother:%d",bb[i]);
}
参考答案:
答案解析: