#include <iostream>
#include <string.h>
using namespace std;
int main()
{
string str;
cout << "Please input something" << endl;
// cin >> str;
getline(cin,str);
int a_count = 0,A_count = 0,num_count = 0,spc_count = 0 ,oth_count = 0;
for(int i=0;i<(int)str.size();i++)
{
if(str.at(i) <= 'z' && str.at(i) >= 'a')
{
a_count ++;
}
else if(str.at(i) <= 'Z' && str.at(i) >= 'A')
{
A_count ++;
}
else if(str.at(i) <= '9' && str.at(i) >= '0')
{
num_count ++;
}
else if(str.at(i) == ' ')
{
spc_count ++;
}
else
{
oth_count ++;
}
}
cout << a_count <<endl;
cout << A_count <<endl;
cout << num_count <<endl;
cout << spc_count <<endl;
cout << oth_count <<endl;
return 0;
}
学习嵌入式的第38天(c++)
最新推荐文章于 2024-09-01 23:06:50 发布