Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <stdio.h>
- using namespace std;
- int main()
- {
- int nrlet = 'z' - 'a' + 1, fr[nrlet], mini = 256, maxi = 0;
- char s[256], cmini, cmaxi;
- gets(s);
- for (int i = 0; i < nrlet; i++)
- fr[i] = 0;
- for (int i = 0; s[i]; i++)
- {
- if ('A' <= s[i] && s[i] <= 'Z')
- s[i] += ' ';
- fr[s[i] - 'a']++;
- }
- for (int i = 0; i < nrlet; i++)
- {
- if (mini > fr[i] && fr[i])
- {
- cmini = char(i) + 'a';
- mini = fr[i];
- }
- if (maxi < fr[i])
- {
- cmaxi = char(i) + 'a';
- maxi = fr[i];
- }
- }
- for (int i = 0; i < nrlet - 1; i++)
- for (int j = i + 1; j < nrlet; j++)
- if (fr[i] > fr[j])
- {
- int aux;
- aux = fr[i];
- fr[i] = fr[j];
- fr[j] = aux;
- }
- cout << "aparitii: ";
- for (int i = 0; i < nrlet; i++)
- if (fr[i])
- cout << fr[i] << ' ';
- cout << endl;
- cout << "litera cu aparitii minime: " << cmini << endl;
- cout << "litera cu aparitii maxime: " << cmaxi;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement