|
#include <stdio.h>
#include <ctype.h>
int main()
{
#define MAX_ASCII 127
#define MIN_ASCII 33
char ascii[MAX_ASCII] = {0, }, c;
int num_digit = 0;
while ((c = getchar()) != EOF) { /* 괄호, =, != 연산자의 사용에 주의하세요. */
if (isalpha(c)) ascii[c]++; /* 가장 핵심은 이 부분! ascii 배열을 잘 보세요. */
if (isdigit(c)) num_digit++;
}
for (c = MIN_ASCII; c < MAX_ASCII; c++)
if (isalpha(c) && ascii[c] > 0)
printf("%c -> %d\n", c, ascii[c]);
printf("Number of digits -> %d\n", num_digit);
return 0;
}
|