#include <stdio.h>
int main(void)
{
char ch;
//character = ch
printf("Please type a character [A-Z or a-z] ('x'to exit):");
scanf("%c", &ch);
switch(ch) //switch statement
{
case 'a':
printf("%c is a vowel.\n", ch);
break;
case 'e':
printf("%c is a vowel.\n", ch);
break;
case 'i':
printf("%c is a vowel.\n", ch);
break;
case 'o':
printf("%c is a vowel.\n", ch);
break;
case 'u':
printf("%c is a vowel.\n", ch);
break;
case 'A':
printf("%c is a vowel.\n", ch);
break;
case 'E':
printf("%c is a vowel.\n", ch);
break;
case 'I':
printf("%c is a vowel.\n", ch);
break;
case 'O':
printf("%c is a vowel.\n", ch);
break;
case 'U':
printf("%c is a vowel.\n", ch);
break;
default:
if(ch != 'x'){
printf("%c is a consonant.\n", ch);
break; }
else if(ch == 'x'){
printf("%c is a consonant.\n", ch);
break; }
}
我在这段代码上遇到了很多麻烦。我已经完美了,但是它需要不断重复,直到输入“x”。尝试了一个while循环,没有任何运气,只是最近尝试了默认的if语句,这也不起作用。如果有人能给我一点见解,我已经很接近了!