原始问题:
用字符数组实现输入任意20个字符统计其中元音字母个数的C程序
include <stdio.h>
define MAX 20
int main()
{
char array[MAX];
int count = 0;
printf("输入任意20个字符: ");
for (int i = 0; i < MAX; i++) { // 输入20个字符并保存到数组中
scanf("%c", &array[i]);
}
for (int j = 0; j < MAX; j++) { // 统计元音字母个数并打印出来
switch(array[j]) { // 利用switch语句,当遇到a、e、i、o、u时,count值加1
case 'a':
case 'e':
case 'i': case 'o': case 'u': count++; break; default: break; } } printf("一共有%d个元音字母 ", count); return 0;}
Prev:如何能变有钱