Unittest для индивидуального задания вариант 4

Этот коммит содержится в:
2024-05-07 23:35:46 +03:00
родитель 99404971c0
Коммит 604455042f
8 изменённых файлов: 55 добавлений и 12 удалений

Просмотреть файл

@@ -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++;