解题思路:
C++利用<cctype>,C用“ctype.h”
注意事项:
参考代码:
#include<iostream> #include<string> #include<cctype> using namespace std; int main(){ string str; getline(cin,str); int a=0,b=0,c=0,d=0; for(int i=0;i<str.size();++i){ if(isalpha(str[i])) a++; else if(isblank(str[i])) b++; else if(isdigit(str[i])) c++; else d++; } cout<<a<<endl<<b<<endl<<c<<endl<<d; return 0;
}
0.0分
0 人评分