#include <stdio.h> #include <string.h> #include <ctype.h> int main() { char str[1001]; while (fgets(str, sizeof(str), stdin)) { size_t len = strlen(str); if(len > 0 && str[len - 1] == '\n') { str[len - 1] = '\0'; } int alpha = 0, space = 0, digit = 0, punct = 0; for(int i = 0; i < len; i++) { if(isalpha(str[i])) alpha++; else if(isspace(str[i])) space++; else if(isdigit(str[i])) digit++; else if(ispunct(str[i])) punct++; } // printf("%s\n", str); printf("%d\n%d\n%d\n%d\n",alpha, space, digit, punct); } return 0; }