number of alphabet (small)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | #include <stdio.h> #include <string.h> #define ALPHABET_SIZE 26 int main (int argc, char** argv) { char* sentence = "hello world"; int Lower_Case[ALPHABET_SIZE] = { 0, }; int size = strlen (sentence); int index = 0; for (index = 0; index < size; index++) { if (*(sentence + index) < 'a' && *(sentence + index) > 'z') continue; Lower_Case[(char) *(sentence + index) - 'a']++; } // print printf ("%s\n", sentence); for (index = 0; index < ALPHABET_SIZE; index++) { if (*(Lower_Case + index) == 0) continue; printf ("%c : %d\n", index + 'a', Lower_Case[index]); } return 0; } | cs |
0 개의 댓글:
댓글 쓰기