从终端上输入若干个字符,对其中的元音字母进行统计。
#include <stdio.h>
#include <stdlib.h>
static void test3(void)
{
int ct_a = 0,ct_e = 0,ct_i = 0,ct_o = 0,ct_u = 0;
int ch;
ch = getchar();
while(ch != '#')
{
switch(ch)
{
case 'a':
case 'A':
ct_a ++;
break;
case 'e':
case 'E':
ct_e ++;
break;
case 'i':
case 'I':
ct_i ++;
break;
case 'o':
case 'O':
ct_o ++;
break;
case 'u':
case 'U':
ct_u ++;
break;
default:
ptus("请再输入一次");
break;
}
}
printf("A/a is %d E/e is %d I/I is %d O/o is %d U/u is %d\n",ct_a,ct_e,ct_i,ct_o,ct_u);
}
int main()
{
test3();
exit(0);
}