code: файл реализации

main
KapitonovMikA 11 месяцев назад
Родитель 007108e1a0
Сommit 16c544161f

@ -0,0 +1,55 @@
#include <iostream>
#include <conio.h>
#include <vector>
#include <stdlib.h>
#include "text.h"
using namespace std;
void
show_histogram_text(const vector<size_t> bins, size_t bin_count){
const size_t MAX_ELEMENT = 76;
double max_count = bins[0];
for (size_t j=0; j < bin_count; j++){
if (bins[j] > max_count) {
max_count = bins[j];
}
}
vector<size_t> height(bin_count);
for (size_t j=0; j < bin_count; j++){
height[j] = MAX_ELEMENT * (bins[j]/max_count);
}
if (max_count > MAX_ELEMENT){
for (size_t j=0; j < bin_count; j++)
{
if (bins[j] < 100) {
cout << " ";
if (bins[j] < 10){
cout << " ";
}
}
cout << bins[j] << "|";
for (size_t i=0; i < height[j]; i++){
cout << "*";
}
cout << endl;
}
}
else {
for (size_t j=0; j < bin_count; j++)
{
if (bins[j] < 100) {
cout << " ";
if (bins[j] < 10){
cout << " ";
}
}
cout << bins[j] << "|";
for (size_t i=0; i < bins[j];i++){
cout << "*";
}
cout << endl;
}
}
}
Загрузка…
Отмена
Сохранить