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

..

Ничего общего в коммитах. '68dc612a91336cb2aa22b59398431a4a63734479' и 'd94b3e17d938a5911ad4d36df64a415cc19525fc' имеют совершенно разные истории.

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

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

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

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

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

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

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

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

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

@ -1,38 +0,0 @@
<?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>

@ -1,28 +0,0 @@
#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);
}
Загрузка…
Отмена
Сохранить