6.3w+
社区成员
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
void show(const char *a)
{
int i,j=0;
for(i=0;a[i]!='\0';i++)
{
if((a[i]>'a'&&a[i] <'z') ||(a[i]>'A'&&a[i] <'Z'))
j++;
}
cout <<"共有" <<j <<"个字母!" <<endl;
}
void main()
{
string str;
cout <<"input the sentence:" <<endl;
cin>>str;
show(str.c_str());
}
#include <iostream>
#include <string>
#define pause system("pause")
using std::cin;
using std::cout;
using std::endl;
using std::string;
#include<iostream>
int n;
void show(char *a)
{
int i,j=0;
for(i=0;i<n;i++)
{
if((a[i]>='a'&&a[i] <='z') || (a[i]>='A'&&a[i] <='Z'))
j++;
}
cout <<"共有" <<j <<"个字母!" <<endl;
}
void main()
{
int i = 0;
char b[100];
cout <<"input the sentence:" <<endl;
for(i = 0; i<100; i++)
b[i] = NULL;
i = 0;
while((b[i]=getchar())!='\n'){
i++;
}
n = i;
show(b);
pause;
}