求助:switch问题
#include <stdio.h>
void main()
{
char letter;
int vowel_count = 0;
int consonant_count = 0;
for (letter = 'A'; letter <= 'Z'; letter++)
switch (letter) {
case 'A':
case 'E':
case 'I':
case 'O':vowel_count++;
break;
case 'U':
default: consonant_count++;
};
printf("The number of vowels is %d\n", vowel_count);
printf("The number of vowels is %d\n", consonant_count);
}
运行结果:The number of vowels is 4
The number of vowels is 22
请问 第一个结果“4”是怎么得出的?
case‘o’应该只执行了一次就跳出了switch了,为什么vowel_count的值为4了?
[此贴子已经被作者于2007-10-24 22:49:58编辑过]