int main() { string str; cout << "输入字符串:"; getline(cin,str); int size =str.size(); int big = 0; int small = 0; int num = 0; int space = 0; int other = 0; for(int i=0;i<size;i++) { if(str[i]<='Z'&&str[i]>='A') { big++; } else if(str[i]<='z'&&str[i]>='a') { small++; } else if(str[i]<='9'&&str[i]>='0') { num++; } else if(str[i]==' ') { space++; } else other++; } cout << "big=" << big << endl; cout << "small=" << small << endl; cout << "num=" << num << endl; cout << "space=" << space <<endl; cout << "other=" << other <<endl; return 0; }