一个C++简单编程请教

来源:百度知道 编辑:UC知道 时间:2024/09/22 01:51:03
编写一个函数,统计一条英文句子中字母的个数,在主程序中实现输入输出

#include<iostream>
#include<string>
#include <cctype>
using namespace std;
int main()
{
string s;
int c=0;
cin>>s;
for (string::size_type index=0;index!=s.size();++index)
{
if (isalpha(s[index]))
{
c++;
}
}
cout<<c<<endl;
return 0;
}

一楼的回答很好。。。
我就不用再写了。。。