多谢
#include <iostream>using namespace std;
int main()
{
char str[100];
int i=0,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<<endl;
cout<<"the number of letter is"<<b<<endl;
cout<<"the number of figure is"<<c<<endl;
cout<<"the number of else character"<<d<<endl;
return 0;
}
[ 本帖最后由 wjffirework 于 2015-3-15 14:35 编辑 ]