while 语句的用法#include //#include using namespace std;int main() { char ch; int aCnt=0,eCnt=0,iCnt=0,oCnt=0,uCnt=0,consonantCnt = 0; while ( cin >> ch ) switch ( ch ) { case 'a':case 'A':++aCnt;break;case 'e':case 'E':++eCnt;break;case 'i':cas

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/09 00:32:07
while语句的用法#include//#includeusingnamespacestd;intmain(){charch;intaCnt=0,eCnt=0,iCnt=0,oCnt=0,uCnt=0

while 语句的用法#include //#include using namespace std;int main() { char ch; int aCnt=0,eCnt=0,iCnt=0,oCnt=0,uCnt=0,consonantCnt = 0; while ( cin >> ch ) switch ( ch ) { case 'a':case 'A':++aCnt;break;case 'e':case 'E':++eCnt;break;case 'i':cas
while 语句的用法
#include
//#include
using namespace std;
int main()
{
char ch;
int aCnt=0,eCnt=0,iCnt=0,oCnt=0,uCnt=0,
consonantCnt = 0;
while ( cin >> ch )
switch ( ch )
{
case 'a':case 'A':
++aCnt;
break;
case 'e':case 'E':
++eCnt;
break;
case 'i':case 'I':
++iCnt;
break;
case 'o':case 'O':
++oCnt;
break;
case 'u':case 'U':
++uCnt;
break;
default:
if ( isalpha( ch ))
++consonantCnt;
break;
}
cout

while 语句的用法#include //#include using namespace std;int main() { char ch; int aCnt=0,eCnt=0,iCnt=0,oCnt=0,uCnt=0,consonantCnt = 0; while ( cin >> ch ) switch ( ch ) { case 'a':case 'A':++aCnt;break;case 'e':case 'E':++eCnt;break;case 'i':cas
你这个while的判断是ch的值,ch是获取的按键值,是其ascii码,不可能为零的,所以不会退出循环,哪怕你输的是零,建议可以加个判断,例如while((cin>>ch)!=`0`)