#include <stdio.h>
#include <stdlib.h>
int main() {
char string[100];
char tabela[256];
// Limpa a tabela.
for (int i = 0; i < 256; i++) {
tabela[i] = 0;
}
// Lê a frase do usuário.
printf ("\nEscreva um texto: \n"); fgets(string
, 100, stdin
);
// Monta a tabela de frequências.
for (int i = 0; i < tamanho; i++) {
tabela[string[i]]++;
}
// Busca o índice de maior ocorrência na tabela.
int maior = 0;
char letra = '\0';
for (int i = 0; i < 256; i++) {
int t = tabela[i];
if (t > maior) {
maior = t;
letra = (char) i;
}
}
// Mostra o resultado.
printf("\nO caractere '%c' aparece %d vezes.\n", letra
, maior
);
// Fim.
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCmludCBtYWluKCkgewogICAgY2hhciBzdHJpbmdbMTAwXTsKICAgIGNoYXIgdGFiZWxhWzI1Nl07CgogICAgLy8gTGltcGEgYSB0YWJlbGEuCiAgICBmb3IgKGludCBpID0gMDsgaSA8IDI1NjsgaSsrKSB7CiAgICAgICAgdGFiZWxhW2ldID0gMDsKICAgIH0KCiAgICAvLyBMw6ogYSBmcmFzZSBkbyB1c3XDoXJpby4KICAgIHByaW50ZiAoIlxuRXNjcmV2YSB1bSB0ZXh0bzogXG4iKTsKICAgIGZnZXRzKHN0cmluZywgMTAwLCBzdGRpbik7CiAgICBpbnQgdGFtYW5obyA9IHN0cmxlbihzdHJpbmcpOwoKICAgIC8vIE1vbnRhIGEgdGFiZWxhIGRlIGZyZXF1w6puY2lhcy4KICAgIGZvciAoaW50IGkgPSAwOyBpIDwgdGFtYW5obzsgaSsrKSB7CiAgICAgICAgdGFiZWxhW3N0cmluZ1tpXV0rKzsKICAgIH0KCiAgICAvLyBCdXNjYSBvIMOtbmRpY2UgZGUgbWFpb3Igb2NvcnLDqm5jaWEgbmEgdGFiZWxhLgogICAgaW50IG1haW9yID0gMDsKICAgIGNoYXIgbGV0cmEgPSAnXDAnOwogICAgZm9yIChpbnQgaSA9IDA7IGk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