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

31 строка
709 B
C++

#include "text.h"
#include "svg.h"
#include <string>
#include <iostream>
using namespace std;
void
show_histogram_svg(const vector<double>& bins, size_t MAX_ASTERISK, size_t bin_count) {
double max_count = bins[0];
for (double x : bins) {
if (x > max_count) {
max_count = x;
}
}
for (int i = 0; i < bin_count; i++) {
double count = bins[i];
size_t height = MAX_ASTERISK * (static_cast<double>(count) / max_count);
string line(height, '*');
if (bins[i] < 100)
{
cout << ' ';
}
if (bins[i] < 10)
{
cout << ' ';
}
cout << bins[i] << "|" << line << endl;
}
}