#include <iostream>
using namespace std;
int main()
{
cout << "请输入一串字符串:" << endl;
string str;
getline(cin,str);
int b=str.size();
int dx=0,xx=0,kg=0,sz=0,qt=0;
for(int i=0;i<b;i++)
{
if(str[i]>='a'&&str[i]<='z')
{
xx++;
}
else if(str[i]>='A'&&str[i]<='Z')
{
dx++;
}
else if(str[i]>='0'&&str[i]<='9')
{
sz++;
}
else if(str[i]==' ')
{
kg++;
}
else
{
qt++;
}
}
cout << "dx=" << dx <<endl;
cout << "xx=" << xx <<endl;
cout << "kg=" << kg <<endl;
cout << "sz=" << sz <<endl;
cout << "qt=" << qt <<endl;
return 0;
}
2024.8.28
最新推荐文章于 2024-11-06 23:59:11 发布