西安网站 建设,2016年网站推广方法,哪里网站备案快,体育类网站模板提示并输入一个字符串#xff0c;统计该字符中大写#xff0c;小写字母个数#xff0c;数字个数#xff0c;空格个数以及其他字符个数#xff0c;要求使用C风格字符串完成
#include iostreamusing namespace std;int main()
{string str;int A0,a0,num0,backspac…提示并输入一个字符串统计该字符中大写小写字母个数数字个数空格个数以及其他字符个数要求使用C风格字符串完成
#include iostreamusing namespace std;int main()
{string str;int A0,a0,num0,backspace0,other0;cout 请输入一个字符串: ;getline(cin, str);for(int i 0;i str.size(); i ){if((int)A str[i] str[i] (int)Z){A;}else if(97 str[i] str[i] 123){a;}else if(0 str[i] str[i] 9){num;}else if(str[i] \40){backspace;}else{other;}}cout 大写有: A 个小写有 a 个数字有: num 个空格有 backspace 个其他字符有 other 个。 endl;return 0;
}