题解 | #判断是元音还是辅音#
判断是元音还是辅音
http://www.nowcoder.com/practice/7eb4df4d52c44d309081509cf52ecbc4
// 创建数组,通过for循环判断,
// 比在for里面添加多个判断条件要美观许多
// 不过,优越性好像也仅此,不过也算是增加一种解题思路吧。
#include<iostream>#include<math.h>
using namespace std;
int main()
{
int i;
char a;
char arr[10] = { 'a','e','i','o','u','A','E','I','O','U' };
while (cin >> a)
{
for (i = 0; i < 10; i++)
{
if (a == arr[i])
break;
}
if (i < 10)
cout << "Vowel" << endl;
else
cout << "Consonant" << endl;
}
system("pause");
return 0;
}