题目;编一函数,统计字符串的个数,并分别统计字母及数字的个数. #include<iostream.h>
char *str;
void a()
{
int x=0,y=0,z=0;
while(*str++!='\0')
{
x++;
if('a'<=*str&&*str<='z'||'A'<=*str&&*str<='Z')
y++;
if(0<=*str&&*str<=9)
z++;
}
cout<<"x="<<x<<endl;
cout<<"y="<<y<<endl;
cout<<"z="<<z<<endl;
}
void main()
{
cin>>*str;
a(*str);
} |