code: сделал вариант 5 через функцию

main
Danila 2 лет назад
Родитель 17c57fda8d
Сommit e431557ac6

@ -37,6 +37,8 @@
<Unit filename="histogram.h" />
<Unit filename="histogram_internal.h" />
<Unit filename="main.cpp" />
<Unit filename="svg.cpp" />
<Unit filename="svg.h" />
<Unit filename="text.cpp" />
<Unit filename="text.h" />
<Extensions>

@ -6,6 +6,12 @@
#include "svg.h"
using namespace std;
size_t emptiness_width (size_t a, size_t b)
{
size_t c = a - b;
return c;
}
void
svg_begin(double width, double height)
{
@ -36,7 +42,6 @@ svg_rect(double x, double y, double width, double height, string stroke = "black
}
void
show_histogram_svg(const vector<size_t>& bins)
{
@ -67,11 +72,10 @@ show_histogram_svg(const vector<size_t>& bins)
for (size_t bin : bins)
{
double bin_width = (MAX_WIDTH)*(bin/max_count);
svg_rect(MAX_WIDTH-bin_width, top, bin_width, BIN_HEIGHT, BLACK, RED);
svg_rect(emptiness_width(MAX_WIDTH, bin_width), top, bin_width, BIN_HEIGHT, BLACK, RED);
svg_text(TEXT_LEFT+MAX_WIDTH, top + TEXT_BASELINE, to_string(bin));
top += BIN_HEIGHT;
}
svg_end();
}

@ -1,9 +1,11 @@
#define DOCTEST_CONFIG_NO_MULTITHREADING
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include <vector>
#include "doctest.h"
#include "project/histogram_internal.h"
#include "project/svg.h"
TEST_CASE("distinct positive numbers 1")
/* TEST_CASE("distinct positive numbers 1")
{
double min = 0;
double max = 0;
@ -39,3 +41,16 @@ TEST_CASE("vector with same elements") {
CHECK(min == 2);
CHECK(max == 2);
}
*/
TEST_CASE("distinct positive numbers 1")
{
double min = 0;
double max = 0;
find_minmax({1, 2}, min, max);
CHECK(min == 1);
CHECK(max == 2);
}

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