PHP小丑 发表于 2021-12-30 21:20:54

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]
查看完整版本: C++统计不同类型字符出现次数