1885 - 【C语言训练】数字母

通过次数

0

提交次数

0

时间限制 : 1 秒 内存限制 : 128 MB

输入一个字符串,数出其中的字母的个数.

题目输入

一个字符串,不包含空格(长度小于100)

题目输出

字符串中的字母的个数

输入/输出样例

输入格式

124lfdk54AIEJ92854&%$GJ

输出格式

10

C++解答

#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main()
{
	string s;
	getline(cin,s);
	int len=s.size(),ans=0;
	for (int i=0; i<len; i++)
		if (isalpha(s[i])) ans++;
	cout<<ans<<endl;
	return 0;
}