多组输入,每行输入一个字母。
针对每组输入,输出为一行,如果输入字母是元音(包括大小写),输出“Vowel”,如果输入字母是非元音,输出“Consonant”。
A b
Vowel Consonant
#include <stdio.h> int main() { char ch = 0; while (scanf("%c", &ch) == 1) { //只接受输入的字符,enter被吸收,释放掉 getchar(); if (ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'I' || ch == 'i' || ch == 'O' || ch == 'o' || ch == 'U' || ch == 'u') printf("Vowel\n"); else { //如果输入的是非字母,不输出 if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) printf("Consonant\n"); } } return 0; }
#include <stdio.h> int main() { char s[] = "aeiouAEIOU"; char* p = NULL; char input = 0; int flag = 0; while (scanf("%c", &input) != EOF) { //拿走空字符 getchar(); //重置p为字符串首元素 p = s; //重置标志为0 flag = 0; //判断是否为元音 while (*p) { if (*p == input) { flag = 1; break; } p++; } //进行相应输出 if (flag) { printf("Vowel\n"); } else { printf("Consonant\n"); } } return 0; }
#include <stdio.h> int main() { char ch; while((ch=getchar())!=EOF){ //由于getchar()会读到'\n'(回车),所以要加个getchar()吃掉空格; getchar(); switch(ch){ case 'A': case 'E': case 'I': case 'O': case 'U': case 'a': case 'e': case 'i': case 'o': case 'u':printf("Vowel\n");break; default:printf("Consonant\n"); } } return 0; }
//BC53 判断是元音还是辅音 #include "stdio.h" int main(){ char ch; while((scanf("%c",&ch) != EOF)){ getchar(); if((ch=='A') || (ch=='E') || (ch=='I') || (ch=='O') || (ch=='U') || (ch=='a') || (ch=='e') || (ch=='i') || (ch=='o') || (ch=='u')){ printf("Vowel\n"); continue; } else { printf("Consonant\n"); } } return 0; }
#include <stdio.h> int main() { char c = 0; char arr[] = "AaEeIiOoUu"; while (scanf("%c", &c) != EOF) { if (c == '\n') continue; int i = 0; for ( i = 0; i < 10; i++) { if (c == arr[i]) { printf("%s\n", "Vowel"); break; } } if (i == 10) { printf("%s\n", "Consonant"); } } return 0; }