题目链接:http://115.28.203.224/problem.php?cid=1010&pid=11
题目描述
输入一个字符串,数出其中的字母的个数.
输入
一个字符串,不包含空格(长度小于100)
输出
字符串中的字母的个数
样例输入
124lfdk54AIEJ92854&%$GJ
样例输出
10
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #define maxlen 100 5 using namespace std; 6 char s, str[maxlen]; 7 int main() 8 { 9 int i, n = 0; 10 gets(str); 11 for (i = 0; str[i] != '\0'; i++) 12 { 13 s = str[i]; 14 if ((s>=65 && s<=90) || (s>=97 && s<=122)) 15 n++; 16 } 17 cout<<n; 18 return 0; 19 }