文字の行の小さなキーボード入力からの統計文字、大文字、数字、文字、およびその他の文字の数。
C言語VS-2019
#include<stdio.h>
#include<ctype.h>
int main()
{
printf("Please input the number of string:");
int num = 0;
int num_low = 0, num_n = 0, num_c = 0;
scanf_s("%d", &num);
for (int i = 0; i < num; i++)
{
char m=getchar();
if (isdigit(m))//数字
{
num_n++;
}
if (islower(m))
{
num_low++; //小写字母
}
if (isupper(m))
{
num_c++; //大写字母
}
}
printf("数字个数:%d,小写字母个数:%d,大写字母个数:%d,其余:%d\n",num_n,num_low,num_c,num-num_c-num_low-num_n-1);
return 0;
}