请教前辈、高手一个循环的小问题,新人求指教
#include<iostream>
int main()
{
using namespace std;
char words[80][20];//二维数组
cout<<"Enter words (q to quit):";
int i=0;
do
{
cin>>words[i];
i++;
}while(!(words[i][0]=='q'&&words[i][1]=='\0'));//读取输入的单词,直到只输入q为止
int count1=0,count2=0,others=0;
for(int j=0;j<i-1;j++)
{
if(isalpha(words[j][0]))//判断单词是否以字母开头
switch(words[j][0])
{
case 'a':
case 'e':
case 'i':
case 'o':
case 'u': count1++;//统计元音字母开头的单词数量
break;
default: count2++;//统计辅音字母开头的单词数量
break;
}
else
others++;//统计以其他字符开头的单词数量
}
cout<<count1<<" words beginning with vowels\n";
cout<<count2<<" words beginning with consonants\n";
cout<<others<<" others \n";//输出各类单词的数量
return 0;
}
写了这个程序好像无法跳出那个do while循环,不知道测试条件的问题在哪里,又或是我的二维数组用得不对?
求帮帮忙,感激不尽