Сравнить коммиты

...

2 Коммитов

Автор SHA1 Сообщение Дата
Andrey 68dc612a91 final
2 лет назад
Andrey 7829d31756 class
2 лет назад

10
.gitignore поставляемый

@ -0,0 +1,10 @@
/bin
/obj
/lab01.depend
/lab01.layout
/main.exe
/main.o
/unittest.depend
/unittest.layout
/unittest1.depend

@ -5,24 +5,30 @@
using namespace std;
void
bool
find_minmax(const vector<double>& numbers, double& min1, double& max1)
{
if (numbers.size() == 0) {
return false;
}
else {
max1 = numbers[0];
min1 = numbers[0];
}
for(size_t i = 0; i < numbers.size(); i++)
{
if (numbers[i] > max1) max1 = numbers[i];
if (numbers[i] < min1) min1 = numbers[i];
}
return;
return true;
}
vector<double>
make_histogram(const vector<double>& numbers, size_t bin_count)
{
double min1, max1;
find_minmax(numbers, min1, max1);
if (!find_minmax(numbers, min1, max1))
cout << "error in find_minmax: empty vector";
vector<double> bins;
bins.resize(bin_count);

@ -1,5 +1,5 @@
#pragma once
#include <vector>
void
bool
find_minmax(const std::vector<double>& numbers, double& min1, double& max1);

@ -33,10 +33,18 @@
<Add option="-fexceptions" />
</Compiler>
<Unit filename=".gitignore" />
<Unit filename="histogram.cpp" />
<Unit filename="histogram.h">
<Option target="&lt;{~None~}&gt;" />
</Unit>
<Unit filename="histogram_internal.h">
<Option target="&lt;{~None~}&gt;" />
</Unit>
<Unit filename="main.cpp" />
<Unit filename="svg.cpp" />
<Unit filename="svg.h">
<Option target="&lt;{~None~}&gt;" />
</Unit>
<Extensions>
<lib_finder disable_auto="1" />
</Extensions>

@ -1,6 +1,7 @@
#include "svg.h"
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
@ -28,6 +29,13 @@ void svg_rect(double x, double y, double width, double height, string stroke = "
cout << "<rect x='" << x << "' y='" << y << "' width='" << width << "' height='" << height << "' stroke='" << stroke << "' fill='#" << fill << fill << fill << "' />";
}
void color_find(double bin, int maxb, int& color){
color = (10 - (bin * 9) / maxb);
if (color < 0) { cout << "cant take color";
color = 9;
}
}
void
show_histogram_svg(const vector<double>& bins) {
@ -43,20 +51,21 @@ show_histogram_svg(const vector<double>& bins) {
double top = 0;
const size_t MAX_ASTERISK = IMAGE_WIDTH - TEXT_WIDTH;
double maxb = bins[0];
int maxb = bins[0];
int color;
for (size_t j = 1; j < bins.size(); j++)
{
if (bins[j] > maxb) maxb = bins[j];
}
double maxb1 = maxb * BLOCK_WIDTH;
int maxb1 = maxb * BLOCK_WIDTH;
for (size_t bin : bins) {
double bin_width;
int color = (10 - (bin * 9) / maxb);
color_find(bin, maxb, color);
if (maxb1 > MAX_ASTERISK)
{

@ -0,0 +1,4 @@
#pragma once
void
color_find(double bin, int maxb, int& color);

@ -31,6 +31,9 @@
<Compiler>
<Add option="-Wall" />
</Compiler>
<Unit filename="histogram.cpp" />
<Unit filename="histogram_internal.h" />
<Unit filename="unittest.cpp" />
<Extensions />
</Project>
</CodeBlocks_project_file>

@ -6,9 +6,7 @@
TEST_CASE("distinct positive numbers") {
double min = 0;
double max = 0;
find_minmax({1, 2}, min, max);
CHECK(min == 1);
CHECK(max == 2);
CHECK(find_minmax({}, min, max) == false);
}
TEST_CASE("distinct identical numbers") {

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="unittest1" />
<Option pch_mode="2" />
<Option compiler="gfortran" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/unittest1" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gfortran" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/unittest1" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gfortran" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
</Compiler>
<Extensions>
<lib_finder disable_auto="1" />
</Extensions>
</Project>
</CodeBlocks_project_file>

@ -0,0 +1,28 @@
#define DOCTEST_CONFIG_NO_MULTITHREADING
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "doctest.h"
#include "svg_internal.h"
TEST_CASE("color standart") {
int color = 0;
color_find(1, 5, color);
CHECK(color == 8);
}
TEST_CASE("color equal") {
int color = 0;
color_find(5, 5, color);
CHECK(color == 1);
}
TEST_CASE("color sr") {
int color = 0;
color_find(3, 5, color);
CHECK(color == 4);
}
TEST_CASE("color nonsr") {
int color = 0;
color_find(7, 5, color);
CHECK(color == 9);
}
Загрузка…
Отмена
Сохранить