c++语句:while ((s[i]=getchar())!='\n') i++;可否换成cin>>s;??
原程序:#include<iostream>usingnamespacestd;intmain(){intupper=0,lower=0,digit=0,sp...
原程序: #include <iostream> using namespace std; int main() {int upper=0,lower=0,digit=0,space=0,other=0,i=0; char *p,s[20]; cout<<"input string:"; while ((s[i]=getchar())!='\n') i++; p=s; while (*p!='\n') {if (('A'<=*p) && (*p<='Z')) ++upper; else if (('a'<=*p) && (*p<='z')) ++lower; else if (*p==' ') ++space; else if ((*p<='9') && (*p>='0')) ++digit; else ++other; p++; } cout<<"upper case:"<<upper<<endl<<"lower case:"<<lower<<endl; cout<<"space:"<<space<<endl<<"digit:"<<digit<<endl<<"other:"<<other<<endl; return 0; } 换了后输出很乱
展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询