思维导图


#include <iostream>
#include <string.h>
using namespace std;
int main()
{
string str;
cout << "请输入一个字符串:" <<endl;
getline(cin,str);
int num=0,high=0,low=0,blank=0,other=0;
for(int i=0;i<(int)str.size();i++)
{
if(str.at(i)>='0'&&str.at(i)<='9')
{
num++;
}
else if (str.at(i)>='A' && str.at(i)<='Z')
{
high++;
}
else if (str.at(i)>='a' && str.at(i)<='z')
{
low++;
}
else if (str.at(i)==' ')
{
blank++;
}
else
{
other++;
}
}
cout << "数字有" << num << "个" << endl;
cout << "大写字母有" << high << "个" << endl;
cout << "小写字母有" << low << "个" << endl;
cout << "空格有" << blank << "个" << endl;
cout << "其他字符有" << other << "个" << endl;
return 0;
}


508

被折叠的 条评论
为什么被折叠?



