解题思路:
注意事项:
参考代码:
#include<stdio.h>
#include<string.h>
#define Long 40
int main()
{
void scanf_str(char* a, int size, int* letter, int* num, int* space, int* other);
char a[Long]="";
int letter = 0, num = 0, space = 0, other = 0,size;
gets(a);
size = strlen(a);
scanf_str(a, size,&letter, &num, &space, &other);
printf("%d %d %d %d", letter, num, space, other);
return 0;
}
void scanf_str(char* a, int size, int* letter,int* num,int* space, int* other)
{
int i;
for (i = 0; i < size; i++)
{
if ((*(a + i) >= 'A' && *(a + i) <= 'Z') || (*(a + i) >= 'a' && *(a + i) <= 'z'))
(*letter)++;
else if (*(a + i) >= '0' && *(a + i) <= '9')
(*num)++;
else if (*(a + i) == ' ')
(*space)++;
else
(*other)++;
}
}
0.0分
0 人评分