猿问

指出输入单词以元音、辅音开头单词还有其他的数目,下面程序运行时只有输入而不输出,什么情况

#include<iostream>
#include<cctype>
#include<string>

using namespace std;

int main()
{
 cout << "Enter words (q to quit);"<<endl;
 char words[20];
 int count1 = 0;
 int count2 = 0;
 int count3 = 0;
 while (cin >> words)
 {
  if (isalpha(words[0]))
  {
   if (words[0] == 'a' || words[0] == 'e' || words[0] == 'i' || words[0] == 'o' || words[0] == 'u' ||
    words[0] == 'A' || words[0] == 'E' || words[0] == 'I' || words[0] == 'O' || words[0] == 'U')
    count1++;
   else if (words[0] == 'q'&&strlen(words) == 1)
    break;
   else
    count2++;
  }
  count3++;
 }
 cout << "元音:" << count1 << endl
  << "辅音:" << count2 << endl
  << "其他:" << count3 << endl;
 return 0;
}

下面程序运行时只有输入,一直再让输入,而不输出,什么情况


xungeer29
浏览 2187回答 2
2回答
随时随地看视频慕课网APP
我要回答