#include<iostream.h>
void main()
{
char c;
int letter=0,space=0,digit=0,others=0;
cout<<"请输入一串字符C:"<<endl;
cin>>c;
while(cin>>c,c!='\n')//《《这里为什么错了
{
if(c>='a'&&c<='z')
letter++;
else if(c==' ')
space++;
else if(c>=0&&c<=9)
digit++;
else
others++;
}
cout<<"这串字符里面有:"<<endl;
cout<<"英文字母:"<<letter<<"个"<<endl;
cout<<"空格:"<<space<<"个"<<endl;
cout<<"数字:"<<digit<<"个"<<endl;
cout<<"其他字符:"<<others<<"个"<<endl;
}
void main()
{
char c;
int letter=0,space=0,digit=0,others=0;
cout<<"请输入一串字符C:"<<endl;
cin>>c;
while(cin>>c,c!='\n')//《《这里为什么错了
{
if(c>='a'&&c<='z')
letter++;
else if(c==' ')
space++;
else if(c>=0&&c<=9)
digit++;
else
others++;
}
cout<<"这串字符里面有:"<<endl;
cout<<"英文字母:"<<letter<<"个"<<endl;
cout<<"空格:"<<space<<"个"<<endl;
cout<<"数字:"<<digit<<"个"<<endl;
cout<<"其他字符:"<<others<<"个"<<endl;
}