#include <iostream>
#include <cstring> // Pentru strlen
using namespace std;
void lowerCase(char linie[]) {
for (int i = 0; linie[i] != '\0'; ++i) {
if (linie[i] >= 'A' && linie[i] <= 'Z') {
linie[i] = linie[i] + ('a' - 'A');
}
}
}
char findMostFrequentLowercase(char text[]) {
int counts[26] = {0};
for (int i = 0; text[i] != '\0'; ++i) {
if (text[i] >= 'a' && text[i] <= 'z') {
counts[text[i] - 'a']++;
}
}
char mostFrequentChar = 0;
int maxCount = 0;
for (int i = 0; i < 26; ++i) {
if (counts[i] > maxCount) {
maxCount = counts[i];
mostFrequentChar = 'a' + i;
}
}
return mostFrequentChar;
}
int main() {
char linie[257]; // 256 caractere + terminator null
char allText[100000] = ""; // Presupunem un text total de maxim 100000 caractere
int allTextLength = 0;
cout << "Introduceti textul (liniile se termina cu linie goala):\n";
while (cin.getline(linie, 257)) {
if (strlen(linie) == 0) {
break;
}
lowerCase(linie);
for (int i = 0; linie[i] != '\0'; ++i) {
allText[allTextLength++] = linie[i];
}
}
allText[allTextLength] = '\0'; // Adăugăm terminator null la textul total
char mostFrequent = findMostFrequentLowercase(allText);
if (mostFrequent) {
cout << "Litera mica cea mai frecventa este: " << mostFrequent << endl;
} else {
cout << "Nu au fost gasite litere mici." << endl;
}
return 0;
}