万网发布网站,公众号怎么制作教程,网站生成海报功能怎么做,公司网站制作公司作业1#xff1a;编程
要求#xff1a;提示并输入一个字符串#xff0c;统计该字符中大写、小写字母个数、数字个数、空格个数以及其他字符个数
代码#xff1a;
#include iostreamusing namespace std;int main()
{string str;cout 请输入一个字…作业1编程
要求提示并输入一个字符串统计该字符中大写、小写字母个数、数字个数、空格个数以及其他字符个数
代码
#include iostreamusing namespace std;int main()
{string str;cout 请输入一个字符串 endl;getline(cin,str);int Bcharcount 0,Lcharcount 0,Spacecount 0,numcount 0,othercount 0;for(int i 0; i (int)str.size() ;i){if( str.at(i) a str.at(i) z ){Lcharcount;}else if( str.at(i) A str.at(i) Z ){Bcharcount;}else if( str.at(i) 0 str.at(i) 9){numcount;}else if( str.at(i) ){Spacecount;}else{othercount;}}cout 大写字母个数 Bcharcount endl;cout 小写字母个数 Lcharcount endl;cout 空格个数 Spacecount endl;cout 数字个数 numcount endl;cout 其他字符个数 othercount endl;return 0;
}效果图 作业2思维导图