题解
【入门】统计字符的个数
1 条题解
-
0
// 读取题目给出的数据。 // 按照题意完成计算。 // 输出最终答案。 #include <bits/stdc++.h> using namespace std; int main(){ char s[25]; cin.getline(s, 25); int da = 0, xiao = 0, shu = 0; for(int i = 0; s[i] != '\0'; i++){ if(s[i] == '#'){ break; } if(s[i] >= 'A' && s[i] <= 'Z'){ da++; } else if(s[i] >= 'a' && s[i] <= 'z'){ xiao++; } else if(s[i] >= '0' && s[i] <= '9'){ shu++; } } cout << da << " " << xiao << " " << shu; return 0; }
- 1