题解 | #字符统计#
字符统计
https://ac.nowcoder.com/acm/problem/22202
输入流get函数获取每个字符进行判断
#include<iostream>
using namespace std;int main(){
int letters=0,digits=0,other=0;
char ch;
ch=cin.get();
while(ch!='?'){
if((ch>=65&&ch<=90)||(ch>=97&&ch<=122)) letters++;
else if(ch>=48&&ch<=57) digits++;
else other++;
ch=cin.get();
}
cout<<"Letters="<<letters<<endl<<"Digits="<<digits<<endl<<"Others="<<other;
}

查看27道真题和解析