题解 | #统计字符#C++,这道题简单到怀疑
统计字符
http://www.nowcoder.com/practice/539054b4c33b4776bc350155f7abd8f5
#include<bits/stdc++.h>
using namespace std;
int main()
{
string str;
while(getline(cin,str))
{
int a=0,b=0,c=0,d=0;
for(auto x:str)
{
if((x>='a'&&x<='z')||(x>='A'&&x<='Z')) a+=1;
else if(x==' ') b+=1;
else if(x>='0'&&x<='9') c+=1;
else d+=1;
}
cout<<a<<endl<<b<<endl<<c<<endl<<d<<endl;
}
}

深信服公司福利 749人发布