Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

53 строки
988 B
C++

#include <iostream>
#include "text.h"
using namespace std;
const size_t SCREEN_WIDTH = 80;
const size_t MAX_ASTERISK = SCREEN_WIDTH -3 -1;
void
show_histogram_text(const vector<size_t>& bins)
{
size_t max_count = 0;
for (size_ count : bins)
{
if (count > max_count)
{
max_count = count;
}
}
for (size_t count :bins)
{
if (count <10)
{
cout << " " << cout <<"|";
}
else if (count < 100)
{
cout<<" " << cout << "|";
}
if (count <1000)
{
cout << cout <<"|";
}
size_t height;
if (max_count <= MAX_ASTERISK)
{
height=count;
}
else
{
height = static_cast<size_t>(MAX_ASTERISK*(static_cast<double>(count)/ max_count));
}
for (size_t j = 0; j< height ; j++)
{
cout << "*";
}
cout << endl;
}
}