

- #include
- //#预处理
- using namespace std;
- //using :使用命名空间的关键字
- //namespace:命名空间的关键字
- //std:标准的命名空间
-
- //程序入口
- int main()
- {//程序的开始
- int daxie = 0,xiaoxie = 0,sum = 0, kong = 0,other = 0;
- string str;
- getline(cin , str);
- for(int i=0 ; i
size() ; i++) - {
- if(str[i]==32)
- {
- kong++;
- }
- else if(48<=str[i]&&str[i]<=57)
- {
- sum++;
- }
- else if(65<=str[i]&&str[i]<=90)
- {
- daxie++;
- }
- else if(97<=str[i]&&str[i]<=122)
- {
- xiaoxie++;
- }
- else
- {
- other++;
- }
- }
- cout << "空格个数=" << kong << endl;
- cout << "数字个数=" << sum << endl;
- cout << "大写字母个数=" << daxie << endl;
- cout << "小写字母个数=" << xiaoxie << endl;
- cout << "其他字符个数=" << other << endl;
- return 0;
- }//程序的结束