Unittest для индивидуального задания вариант 4
Этот коммит содержится в:
@@ -1,3 +0,0 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
void find_minmax(const std::vector<double>& numbers, double& min, double& max);
|
||||
@@ -137,7 +137,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="histogram.h" />
|
||||
<ClInclude Include="histogram_internal.h" />
|
||||
<ClInclude Include="show_histogram.h" />
|
||||
<ClInclude Include="svg.h" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -35,14 +35,11 @@
|
||||
<ClInclude Include="histogram.h">
|
||||
<Filter>Файлы заголовков</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="show_histogram.h">
|
||||
<Filter>Файлы заголовков</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="histogram_internal.h">
|
||||
<Filter>Файлы заголовков</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="svg.h">
|
||||
<Filter>Файлы заголовков</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="show_histogram.h">
|
||||
<Filter>Файлы заголовков</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -21,6 +21,13 @@ void svg_rect(double x, double y, double width, double height,string stroke = "b
|
||||
{
|
||||
cout << "<rect x='" << x << "' y='" << y << "' width='" << width << "' height='" << height << "' fill='" << fill << "' stroke='" << stroke << "' />";
|
||||
}
|
||||
int GetProc(int number_cnt, int bin)
|
||||
{
|
||||
if (number_cnt <= 0) return 0;
|
||||
if (bin < 0) return 0;
|
||||
return 100.0 * bin / number_cnt;
|
||||
}
|
||||
|
||||
void show_histogram_svg(const vector<double>& bins, int number_cnt) {
|
||||
const auto IMAGE_WIDTH = 400;
|
||||
const auto IMAGE_HEIGHT = 300;
|
||||
@@ -40,7 +47,7 @@ void show_histogram_svg(const vector<double>& bins, int number_cnt) {
|
||||
for (size_t bin : bins) {
|
||||
const double bin_width = k * bin;
|
||||
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin));
|
||||
svg_text(IMAGE_WIDTH - TEXT_WIDTH + TEXT_LEFT, top + TEXT_BASELINE, to_string((int)((100.0 / (double)number_cnt) * (double)bin)) + "%");
|
||||
svg_text(IMAGE_WIDTH - TEXT_WIDTH + TEXT_LEFT, top + TEXT_BASELINE, to_string(GetProc(number_cnt,bin)) + "%");
|
||||
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT,"black",colors[color_ptr]);
|
||||
top += BIN_HEIGHT;
|
||||
color_ptr++;
|
||||
|
||||
Ссылка в новой задаче
Block a user