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/06/21 09:15:33
![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](/uploads/image/z/11222276-68-6.jpg?t=while+%E8%AF%AD%E5%8F%A5%E7%9A%84%E7%94%A8%E6%B3%95%23include+%2F%2F%23include+using+namespace+std%3Bint+main%28%29+%7B+char+ch%3B+int+aCnt%3D0%2CeCnt%3D0%2CiCnt%3D0%2CoCnt%3D0%2CuCnt%3D0%2CconsonantCnt+%3D+0%3B+while+%28+cin+%3E%3E+ch+%29+switch+%28+ch+%29+%7B+case+%27a%27%3Acase+%27A%27%3A%2B%2BaCnt%3Bbreak%3Bcase+%27e%27%3Acase+%27E%27%3A%2B%2BeCnt%3Bbreak%3Bcase+%27i%27%3Acas)
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`)