# 分类计数 #### 问题描述 输入一个字符串,请输出这个字符串包含多少个大写字母,多少个小写字母,多少个数字。 #### 输入格式 输入一行包含一个字符串。 #### 输出格式 输出三行,每行一个整数,分别表示大写字母、小写字母和数字的个数。 #### 样例输入 ``` 1+a=Aab ``` #### 样例输出 ``` 1 3 1 ``` #### 评测用例规模与约定 对于所有评测用例,字符串由可见字符组成,长度不超过 100。 ## aop ### before ```cpp #include using namespace std; ``` ### after ```cpp ``` ## 答案 ```cpp int main(int argc, char **argv) { string str; cin >> str; int A = 0, a = 0, number = 0; int len = str.length(); for (int i = 0; i < len; i++) { if (str[i] <= '9' && str[i] >= '0') { number++; } if (str[i] <= 'Z' && str[i] >= 'A') { A++; } if (str[i] <= 'z' && str[i] >= 'a') { a++; } } cout << A << endl; cout << a << endl; cout << number << endl; return 0; } ``` ## 选项 ### A ```cpp int main(int argc, char **argv) { string str; cin >> str; int A = 0, a = 0, number = 0; int len = str.length(); for (int i = 0; i < len; i++) { if (str[i] < '9' && str[i] > '0') { number++; } if (str[i] < 'Z' && str[i] > 'A') { A++; } if (str[i] < 'z' && str[i] > 'a') { a++; } } cout << A << endl; cout << a << endl; cout << number << endl; return 0; } ``` ### B ```cpp int main(int argc, char **argv) { string str; cin >> str; int A = 0, a = 0, number = 0; int len = str.length(); for (int i = 0; i < len; i++) { if (str[i] < 71 && str[i] > 60) { number++; } if (str[i] < 132 && str[i] > 101) { A++; } if (str[i] < 172 && str[i] > 141) { a++; } } cout << A << endl; cout << a << endl; cout << number << endl; return 0; } ``` ### C ```cpp int main(int argc, char **argv) { string str; cin >> str; int A = 0, a = 0, number = 0; int len = str.length(); for (int i = 0; i < len; i++) { if (str[i] < 39 && str[i] > 30) { number++; } if (str[i] < 132 && str[i] > 101) { A++; } if (str[i] <= 'z' && str[i] >= 'a') { a++; } } cout << A << endl; cout << a << endl; cout << number << endl; return 0; } ```