Родитель
393d659027
Сommit
fc08132081
@ -0,0 +1,3 @@
|
|||||||
|
10
|
||||||
|
3 3 4 4 4 4 4 5 5 5
|
||||||
|
3
|
@ -1,30 +1,31 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <math.h>
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
const size_t SCREEN_WIDTH = 80;
|
const size_t SCREEN_WIDTH = 80;
|
||||||
const size_t MAX_ASTERISK = SCREEN_WIDTH - 3 - 1;
|
const size_t MAX_ASTERISK = SCREEN_WIDTH - 3 - 1;
|
||||||
|
|
||||||
void show_histogram_text(const std::vector<size_t> bins, size_t bin_count)
|
void show_histogram_text(const std::vector<size_t> bins, size_t bin_count, const std::vector<double> numbers)
|
||||||
{
|
{
|
||||||
size_t max_count = bins[0];
|
size_t procent=100;
|
||||||
for(size_t x : bins)
|
for(size_t i = 0;i<(bin_count-1);i++){
|
||||||
|
double number = numbers.size();
|
||||||
|
//cout<<number;
|
||||||
|
double proc=(bins[i]/number)*100;
|
||||||
|
procent -=round(proc);
|
||||||
|
printf("%3.0f%%:", proc);
|
||||||
|
for(size_t j = 0;j<bins[i];j++)
|
||||||
{
|
{
|
||||||
if(x > max_count)
|
cout<<"*";
|
||||||
{
|
|
||||||
max_count = x;
|
|
||||||
}
|
}
|
||||||
|
cout<<endl;
|
||||||
}
|
}
|
||||||
for(size_t i = 0;i<bin_count;i++){
|
//procent=Math.round(procent);
|
||||||
size_t height = bins[i];
|
printf("%3d%%:",procent);
|
||||||
printf("%3d:", bins[i]);
|
for(size_t j = 0;j<bins[bin_count - 1];j++)
|
||||||
if(max_count > MAX_ASTERISK)
|
|
||||||
height = MAX_ASTERISK * (static_cast<double>(bins[i]) / max_count);
|
|
||||||
for(size_t j = 0;j<height;j++)
|
|
||||||
{
|
{
|
||||||
cout<<"*";
|
cout<<"*";
|
||||||
}
|
}
|
||||||
cout<<endl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Загрузка…
Ссылка в новой задаче