#include<iostream>
using namespace std;
#include<string>
int main()
{
string str;
while(getline(cin,str))
{
int len=str.size();
int p=0;
int q=0;
while(p<len)
{
if(str[p]==' ')
{ ++p;
if(p<len)
q=p;
}
else p++;
}
int count=0;
while(q<len)
{
if((str[q]>='A'&&str[q]<='Z')||(str[q]>='a'&&str[q]<='z'))
++count;
q++;
}
cout<<count<<endl;
// system("pause");
}
return 0;
}
using namespace std;
#include<string>
int main()
{
string str;
while(getline(cin,str))
{
int len=str.size();
int p=0;
int q=0;
while(p<len)
{
if(str[p]==' ')
{ ++p;
if(p<len)
q=p;
}
else p++;
}
int count=0;
while(q<len)
{
if((str[q]>='A'&&str[q]<='Z')||(str[q]>='a'&&str[q]<='z'))
++count;
q++;
}
cout<<count<<endl;
// system("pause");
}
return 0;
}
本文介绍了一个使用C++编写的简单程序,该程序通过读取标准输入中的文本并统计其中字母的数量。它首先定义了一个字符串变量来存储输入的文本,然后通过遍历字符串中的每个字符来计数字母出现的次数。

被折叠的 条评论
为什么被折叠?



