题目描述
下面是一个已经写好的程序:它读入一行文本,统计其中数字字符(0 到 9)的个数并输出。
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
getline(cin, s);
int cnt = 0;
for (char c : s)
if (c >= '0' && c <= '9') cnt++; // 统计数字字符
cout << cnt << endl;
return 0;
}
你的任务:把这个程序改成统计英文字母(a 到 z 与 A 到 Z)的个数,提交修改后的完整程序,输出字母个数。
输入格式
一行文本,可能包含空格与任意可见字符,长度不超过 (也可能是空行)。
输出格式
一个整数:文本中英文字母的个数。
样例
输入:
Hello, World 123!
输出:
10
字母有 H e l l o W o r l d 共 10 个;数字与标点不算。
数据范围
文本长度 。