C++统计不同类型字符出现次数
#include <iostream>
#include <cstring>
using namespace std;
int main(){
char a;
int b=0,s=0,n=0,o=0;
cin.getline(a,1001);
for(int i=0;i<strlen(a);i++){
if(a>='a'&&a<='z') s++;
else if(a>='A'&&a<='Z') b++;
else if(a>='0'&&a<='9') n++;
else o++;
}
cout<<b<<" "<<s<<" "<<n<<" "<<o<<endl;
return 0;
}
https://blog.51cto.com/u_15467636/4864091
页:
[1]