空格也是字符用getchar

字符统计

http://www.nowcoder.com/questionTerminal/e7fdbd7a3b274fb195791b43c35673f8

include

include

using namespace std;
int main()
{
char s;
int n=0,l=0,o=0;
while(s=getchar(),s!='?')
{
if ( isalpha(s) )
l++ ;
else
if( isdigit(s))
n++;
else o++;
}
cout<<"Letters="<<l<<endl;
cout<<"Digits="<<n<<endl;
cout<<"Others="<<o<<endl;
return 0;
}

全部评论

相关推荐

牛客96763241...:杭电✌️也是打完招呼,没人回吗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务