发布网友 发布时间:2022-04-24 07:35
共1个回答
热心网友 时间:2022-06-17 16:09
#include <stdio.h>
int main()
{
char str[128] = {0};
gets(str);
int i,space,ch,num,other;
space = ch = num = other = 0;
for(i=0;i<sizeof(str);i++)
{
if(str[i] == ' ')
space++;
else if(str[i] >= '0' && str[i] <= '9')
num++;
else if((str[i] >= 'a' && str[i] <= 'z')||
(str[i] >= 'A' && str[i] <= 'Z'))
ch++;
else
other++;
}
printf("ch=%d,num=%d,space=%d,other=%d\n",ch,num,space,other);
}