#include <stdio.h>
#include <conio.h>
#define LEN 50
int main (void) {
//char str[LEN];
char str[LEN] = "5DQj$6X MDaCdj @9IFazB";
char *p = str;
int capCnt, lowCnt, numCnt, othCnt; /*分类计数*/
capCnt = lowCnt = numCnt = othCnt = 0;
//puts ("输入字符串:");
//gets (str);
puts (str);
while (*p) {
if (*p>='A'&&*p<='Z')
capCnt++;
else if (*p>='a'&&*p<='z')
lowCnt++;
else if (*p>='0'&&*p<='9')
numCnt++;
else
othCnt++;
p++;
}
putchar ('\n');
printf ("大写字母%d个\n", capCnt);
printf ("小写字母%d个\n", lowCnt);
printf ("数字%d个\n", numCnt);
printf ("其他字符%d个\n", othCnt);
putchar ('\n');
getch (); /*屏幕暂留*/
return 0;
}
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/63d9f2d3572c11df3db90c6c6d2762d0f703c211?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)