#2
wjffirework2015-03-13 22:15
回复 楼主 wjffirework
|
#include <iostream>
using namespace std;
int main()
{
char str[100];
int i,a=0,b=0,c=0,d=0;
cout<<"input a string: ";
cin>>str;
while(str[i]!='\0');
{
if(str[i]==' ')
a++;
else if(str[i]>='a'&&str[i]<='z'||str[i]>='A'&&str[i]<='Z')
b++;
else if(str[i]>='0'&&str[i]<='9')
c++;
else
d++;
i++;
}
cout<<"the number of space is"<<a;
cout<<"the number of letter is"<<b;
cout<<"the number of figure is"<<c;
cout<<"the number of else character"<<d;
return 0;
}