Skip to content

Instantly share code, notes, and snippets.

@3bugs
Last active August 20, 2023 12:53
Show Gist options
  • Select an option

  • Save 3bugs/877b322793a8e6667870ed4f1a08496e to your computer and use it in GitHub Desktop.

Select an option

Save 3bugs/877b322793a8e6667870ed4f1a08496e to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <ctype.h>
int main() {
int num;
char input;
int charFrequency[26] = {0};
scanf("%d", &num);
for (int i = 0; i < num; ++i) {
scanf(" %c", &input);
input = tolower(input);
charFrequency[input - 'a']++;
}
for (int i = 0; i < 26; ++i) {
if (charFrequency[i] > 0) {
printf("%c: %d\n", 'a' + i, charFrequency[i]);
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment