住房和城乡建设部网站诚信评价,刚刚地震最新消息今天 刚才,推广关键词优化公司,网页设计尺寸怎么测量1思维导图 2试编程
提示并输入一个字符串#xff0c;统计该字符中大写、小写字母个数、数字个数、空格个数以及其他字符个数要求使用C风格字符串完成
#include iostream
#includestring.h
using namespace std;int main()
{string str;cout 思维导图 2试编程
提示并输入一个字符串统计该字符中大写、小写字母个数、数字个数、空格个数以及其他字符个数要求使用C风格字符串完成
#include iostream
#includestring.h
using namespace std;int main()
{string str;cout please enter str:;getline(cin,str);int len str.size();int cap 0;//大写字母int low 0;//小写字母int spa 0;//空格int num 0;//数字int oth 0;//其他for(int i0;ilen;i){if(str[i] a str[i] z){low;}else if(str[i] A str[i] Z){cap;}else if(str[i] 0 str[i] 9){num;}else if(str[i] ){spa;}else{oth;}}cout cap cap endl;cout low low endl;cout num num endl;cout oth oth endl;cout spa spa endl;return 0;
}运行结果