You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
695 B
20 lines
695 B
#include<iostream>
|
|
using namespace std;
|
|
|
|
int main(){
|
|
string str;
|
|
int YinWen_num = 0, KongGe_num = 0, ShuZi_num = 0, Others_num = 0;
|
|
cout<<"please input str:"<<endl;
|
|
getline(cin, str);
|
|
for(int i = 0; i < str.length(); i++){
|
|
if((str[i] - 'a' >= 0 && str[i] - 'z' <= 0) || (str[i] - 'A' >= 0 && str[i] - 'Z' <= 0))YinWen_num++;
|
|
else if(str[i] - '0' >= 0 && str[i] - '9' <= 0)ShuZi_num++;
|
|
else if(str[i] == ' ')KongGe_num++;
|
|
else Others_num++;
|
|
}
|
|
cout<<"YinWen_num is:"<<YinWen_num<<endl;
|
|
cout<<"KongGe_num is:"<<KongGe_num<<endl;
|
|
cout<<"ShuZi_num is:"<<ShuZi_num<<endl;
|
|
cout<<"Others_num is:"<<Others_num<<endl;
|
|
return 0;
|
|
}
|