/* 思路: 1. 获取字符串 2. 遍历字符串 */ #include <iostream> using namespace std; int main() { string str; getline(cin, str); int a = 0, b = 0, c = 0, d = 0; for(auto ch : str){ if(ch >= 'a' && ch <= 'z') a++; else if(ch == ' ') b++; else if(ch >= '0' && ch <= '9') c++; else d++; } cout << a << endl; cout << b << endl; cout << c << endl; cout << d << endl; return 0; } // 64 位输出请用 printf("%lld")