fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MAX_LENGTH = 20;
  5. const int TEN = 10;
  6. int freq[MAX_LENGTH];
  7.  
  8. int main() {
  9. int n, v[MAX_LENGTH + 1];
  10. cin >> n;
  11. int freqDig = 0, aparitii = 0;
  12. for (int i = 1; i <= n; ++i) {
  13. cin >> v[i];
  14. if (v[i] < 0) {
  15. v[i] = -v[i];
  16. }
  17. int copyEl = v[i];
  18. while (copyEl) {
  19. ++freq[copyEl % TEN];
  20. if (freq[copyEl % TEN] > aparitii) {
  21. aparitii = freq[copyEl % TEN];
  22. freqDig = copyEl % TEN;
  23. }
  24. copyEl /= TEN;
  25. }
  26. }
  27.  
  28. for (int i = 0; i < TEN; ++i) {
  29.  
  30. cout << freq[i] <<" ";
  31. }
  32. cout << freqDig;
  33. return 0;
  34. }
Success #stdin #stdout 0.01s 5284KB
stdin
3
122 111 1231
stdout
0 6 3 1 0 0 0 0 0 0 1