本文主要是介绍day01 1.c++对c的扩充,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
#include <iostream>using namespace std;int main()
{string s1;cout << "请输入一个字符串:";getline(cin,s1);int count1=0,count2=0,count3=0,count4=0;int len = s1.length();for(int i=0;i<len;i++){if((s1[i]>='a'&&s1[i]<='z') || (s1[i]>='A'&&s1[i]<='Z')){count1++;}else if(s1[i]>= '0'&&s1[i]<= '9'){count2++;}else if(s1[i] == ' '){count3++;}else{count4++;}}cout << "字母个数 :" << count1<<endl;cout << "数字个数 :" << count2<<endl;cout << "空格个数 :" << count3<<endl;cout << "其他个数 :" << count4<<endl;return 0;
}
这篇关于day01 1.c++对c的扩充的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!