KhatyukhinYS 11 месяцев назад
Родитель e2e310d53b
Сommit e89c8cef00

@ -35,8 +35,7 @@ int main()
max_count=x;
}
}
vector<size_t> procent = make_histogram_proc(in.numbers, in.bin_count, bins);
show_histogram_text(bins,in.bin_count,in.numbers,max_count);
//show_histogram_svg(bins, max_count,procent);
//show_histogram_svg(bins, max_count);
return 0;
}

@ -20,8 +20,8 @@ svg_text(double left, double baseline, std::string text) {
}
void
svg_proc(double left, double baseline,size_t procent) {
std::cout << "<text x='"<< left <<"' y='"<< baseline <<"'>"<< procent <<"%</text>";
svg_proc(double left, double baseline) {
std::cout << "<text x='"<< left <<"' y='"<< baseline<<"</text>";
}
void svg_rect(double x, double y, double width, double height,std::string stroke = "black", std::string fill = "green"){
@ -33,7 +33,7 @@ svg_end() {
}
void
show_histogram_svg(std::vector<size_t> bins,size_t max_count, const std::vector<size_t> procent) {
show_histogram_svg(std::vector<size_t> bins,size_t max_count) {
const auto IMAGE_WIDTH = 400;
const auto IMAGE_HEIGHT = 300;
const auto TEXT_LEFT = 20;
@ -55,7 +55,7 @@ show_histogram_svg(std::vector<size_t> bins,size_t max_count, const std::vector<
const auto TEXT_LEFT_PROCENT = SCALE+TEXT_WIDTH+20;
svg_text(TEXT_LEFT, top + TEXT_BASELINE, std::to_string(bins[i]));
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT);
svg_proc(TEXT_LEFT_PROCENT, top + TEXT_BASELINE,procent[i]);
svg_proc(TEXT_LEFT_PROCENT, top + TEXT_BASELINE);
top += BIN_HEIGHT;
}}
@ -65,7 +65,7 @@ show_histogram_svg(std::vector<size_t> bins,size_t max_count, const std::vector<
const auto TEXT_LEFT_PROCENT = (max_count*SCALE)+TEXT_WIDTH+20;
svg_text(TEXT_LEFT, top + TEXT_BASELINE, std::to_string(bins[i]));
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT);
svg_proc(TEXT_LEFT_PROCENT, top + TEXT_BASELINE,procent[i]);
svg_proc(TEXT_LEFT_PROCENT, top + TEXT_BASELINE);
top += BIN_HEIGHT;
}

@ -5,6 +5,6 @@
using namespace std;
void
show_histogram_svg(std::vector<size_t> bins,size_t max_count, const std::vector<size_t> procent);
show_histogram_svg(std::vector<size_t> bins,size_t max_count);
#endif // SVG_H_INCLUDED

@ -12,8 +12,6 @@ void show_histogram_text(const std::vector<size_t> bins, size_t bin_count, const
size_t procent=100;
for(size_t i = 0;i<(bin_count-1);i++){
double number = numbers.size();
double proc=(bins[i]/number)*100;
procent -=round(proc);
printf("%3d:", bins[i]);
for(size_t j = 0;j<bins[i];j++)
{
@ -23,7 +21,6 @@ void show_histogram_text(const std::vector<size_t> bins, size_t bin_count, const
{
cout<<" ";
}
printf("%3.0f%%",proc);
cout<<endl;
}
//procent=Math.round(procent);
@ -32,9 +29,4 @@ void show_histogram_text(const std::vector<size_t> bins, size_t bin_count, const
{
cout<<"*";
}
for(size_t g=0;g<(max_count-bins[bin_count-1]);g++)
{
cout<<" ";
}
printf("%3d%%",procent);
}

Загрузка…
Отмена
Сохранить