#include<iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int main()
{
char str[100] = {0};
cout << "请输入字符串:" << endl;
gets(str);
// 英文字母
int englishNum = 0;
int otherNum = 0;
for (int i = 0; i < strlen(str);i++)
{
if ((str[i] >= 'A' && str[i] <= 'Z')
|| (str[i]) >= 'a' && str[i] <= 'z')
{
englishNum++;
}
else
{
otherNum++;
}
}
cout << "英文字母: "<< englishNum << "其他字符: " << otherNum << endl;
return 0;
}
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/d8f9d72a6059252d5fc9eb6c379b033b5ab5b9f8?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)