小雨在检查一篇英文短句的构成,想知道字母、数字、其他字符各有多少。阅读程序:
string s = "Noi 2026!";
int z = 0, shu = 0, qi = 0;
for (char ch : s) {
if (isalpha(ch)) z++;
else if (isdigit(ch)) shu++;
else qi++;
}
cout << z << " " << shu << " " << qi;
程序输出是( )
- A. 3 4 1
- B. 7 4 2
- C. 2 4 3
- D. 3 4 2