Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define N 26
- int indexof(char c) {
- return c - 'a';
- }
- char valueof(int i) {
- return 'a' + i;
- }
- char occorrenza(char stringa[]) {
- int occorrenze[N] = { 0 };
- int max = 0, i;
- char *c;
- for (c = stringa; *c != '\0'; c++) {
- i = indexof(*c);
- if (++occorrenze[i] > occorrenze[max]) max = i;
- }
- return valueof(max);
- }
- void main() {
- char test[] = "brrrchefeddddo";
- putchar(occorrenza(test));
- putchar('\n');
- }
Advertisement
Add Comment
Please, Sign In to add comment