很基础的题。
#include <iostream>
#include <string>
using namespace std;
int main()
{
string str;
while (getline(cin, str))
{
int m = 0, n = 0, p = 0, q = 0;
for (int i = 0; i < str.length(); i++)
{
if ((str[i] >= 'a' && str[i] <= 'z') || ((str[i] >= 'A' && str[i] <= 'Z')))
{
m++;
}
else if (str[i] == ' ')
{
n++;
}
else if (str[i] >= '0' && str[i] <= '9')
{
p++;
}
else
q++;
}
cout << m << endl;
cout << n << endl;
cout << p << endl;
cout << q << endl;
}
return 0;
}