题解
2023-10-13 19:59:16
发布于:广东
16阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
int main()
{
string a;
int num = 0, sum = 0, other = 0;
getline(cin, a);
for (int i = 0; i < a.length(); i++)
{
if (a[i] == '?')
{
break;
}
else if ((a[i] >= 'a' && a[i] <= 'z') || (a[i] >= 'A' && a[i] <= 'Z'))
{
sum++;
}
else if (a[i] >= '0' && a[i] <= '9')
{
num++;
}
else
{
other++;
}
}
cout << "Letters=" << sum << endl;
cout << "Digits=" << num << endl;
cout << "Others=" << other << endl;
return 0;
}
这里空空如也
有帮助,赞一个