首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

真痛苦~不知道错哪里解决方案

2012-04-03 
真痛苦~不知道错哪里为毛看不出错误!# includeiostream# includestring# includecctypeusing namesp

真痛苦~不知道错哪里

为毛看不出错误!
# include<iostream>
# include<string>
# include<cctype>
using namespace std;

int main()
{
string word;
cin>>word;
int i,j,k;
i=j=k=0;
while(word!="q")
{
cin.get();
i++;
while(isalpha(word[0]))
{
switch(word[0])
{
case 'A':
case 'a':
  case 'E':
case 'e':
  case 'O':
case 'o':
  case 'U':
case 'u':
  case 'I':
case 'i':j++;
break;
  default: k++;
};
cin>>word;
};
};
  cout<<j<<" words beginning with vowels"<<endl;
  cout<<k<<" words beginning with consonants"<<endl;
  cout<<i-j-k<<" others"<<endl;
  return 0;
}

[解决办法]

C/C++ code
    while(word!="q")    {        cin.get();        i++;        if(isalpha(word[0]))        {            switch(word[0])            {//里边不动            };        };        cin>>word;    }; 

热点排行