#include <iostream>
#include <conio.h>
#include <vector>
#include "text.h"
using namespace std;

void show_histogram_text(const vector<size_t>& bins, size_t max_asterisk)
{
    size_t max_bin_capacity{};
    find_max_capacity(bins, max_bin_capacity);
    size_t height = 0;
    for (int i = 0; i < bins.size(); i++)
    {
        if (bins[i] < 10)
        {
            cout << "  " << bins[i] << "|";
        }
        if ((bins[i] < 100) && (bins[i] > 9))
        {
            cout << " " << bins[i] << "|";
        }
        if (bins[i] >= 100)
        {
            cout << bins[i] << "|";
        }
        if (max_bin_capacity > max_asterisk)
        {
            height = max_asterisk * (static_cast<double>(bins[i]) / max_bin_capacity);
        }
        else
        {
            height = bins[i];
        }
        for (int j = 0; j < height; j++)
        {
            cout << "*";
        }
        cout << "\n";
    }
}