2024-05-24 06:27:34
#include <string>
#include <locale>
#include <iostream>
using namespace std;
// 个数
void GetUpperCount(char * input,
int & upperCount,
int & lowerCount,
int & numCount)
{
for (int i = 0; i < strlen(input); i++)
{
// 统计大写字母个数
if (isupper(input[i]))
{
upperCount++;
}
// 统计小写字母个数
else if (islower(input[i]))
{
lowerCount++;
}
// 统计数字个数
else if (isdigit(input[i]))
{
numCount++;
}
}
}
int main()
{
char szInput[100] = {0};
cout << "请输入字符串: " << endl;
cin >> szInput;
int upperCount = 0;
int lowerCount = 0;
int numCount = 0;
GetUpperCount(szInput, upperCount, lowerCount, numCount);
cout << "大写字母个数: "<< upperCount << endl;
cout << "小写字母个数: "<< lowerCount << endl;
cout << "数字个数:"<< numCount << endl;
}
2024-05-24 05:41:56