Сравнить коммиты
Ничего общего в коммитах. '921a966a37271736cc70edf47ef0b7494541c4d0' и '933469b806d319df5276b3ae7934d5b40bb6b25c' имеют совершенно разные истории.
921a966a37
...
933469b806
@ -1,35 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
|
||||||
<CodeBlocks_layout_file>
|
|
||||||
<FileVersion major="1" minor="0" />
|
|
||||||
<ActiveTarget name="Debug" />
|
|
||||||
<File name="text.cpp" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="339" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="histogram.cpp" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="843" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="histogram_internal.h" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="116" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="text.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="93" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="histogram.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="205" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="main.cpp" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="297" topLine="9" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
</CodeBlocks_layout_file>
|
|
@ -1,42 +0,0 @@
|
|||||||
#include "histogram.h"
|
|
||||||
#include <vector>
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
size_t find_minmax(const std::vector<double>& numbers, double& min, double& max) {
|
|
||||||
if (numbers.empty()) {
|
|
||||||
min = max = 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
min = numbers[0];
|
|
||||||
max = numbers[0];
|
|
||||||
for (double number : numbers) {
|
|
||||||
if (number < min) {
|
|
||||||
min = number;
|
|
||||||
}
|
|
||||||
if (number > max) {
|
|
||||||
max = number;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
std::vector<size_t> make_histogram(const std::vector<double>& numbers, size_t bin_count) {
|
|
||||||
std::vector<size_t> bins(bin_count, 0);
|
|
||||||
if (numbers.empty() || bin_count == 0) {
|
|
||||||
return bins;
|
|
||||||
}
|
|
||||||
double min, max;
|
|
||||||
find_minmax(numbers, min, max);
|
|
||||||
if (max == min) {
|
|
||||||
return bins; // Âîçâðàùàåì ïóñòûå êîðçèíû, findòàê êàê ãèñòîãðàììà íå ìîæåò áûòü ïîñòðîåíà
|
|
||||||
}
|
|
||||||
double bin_width = (max - min) / bin_count;
|
|
||||||
for (double number : numbers) {
|
|
||||||
size_t bin_index = static_cast<size_t>((number - min) / bin_width);
|
|
||||||
if (bin_index >= bin_count) {
|
|
||||||
bin_index = bin_count - 1; // Îáðàáîòêà êðàéíåãî ñëó÷àÿ max == number
|
|
||||||
}
|
|
||||||
bins[bin_index]++;
|
|
||||||
}
|
|
||||||
return bins;
|
|
||||||
};
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <vector>
|
|
||||||
size_t find_minmax(const std::vector<double>& numbers, double& min, double& max);
|
|
||||||
std::vector<size_t> make_histogram(const std::vector<double>& numbers, size_t bin_count);
|
|
@ -1,3 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <vector>
|
|
||||||
size_t find_minmax(const std::vector<double>& numbers, double& min, double& max);
|
|
@ -1,27 +0,0 @@
|
|||||||
#include "text.h"
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
void show_histogram_text(const std::vector<size_t>& bins) {
|
|
||||||
const size_t SCREEN_WIDTH = 80;
|
|
||||||
const size_t MAX_ASTERISK = SCREEN_WIDTH - 3 - 1;
|
|
||||||
size_t max_bin = 0;
|
|
||||||
for (size_t bin : bins) {
|
|
||||||
if (bin > max_bin) {
|
|
||||||
max_bin = bin;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t bin_value : bins) {
|
|
||||||
if (bin_value < 100) std::cout << " ";
|
|
||||||
if (bin_value < 10) std::cout << " ";
|
|
||||||
std::cout << bin_value << " |";
|
|
||||||
size_t height = bin_value;
|
|
||||||
if (max_bin > MAX_ASTERISK) {
|
|
||||||
height = static_cast<size_t>(MAX_ASTERISK * (static_cast<double>(bin_value) / max_bin));
|
|
||||||
}
|
|
||||||
for (size_t i = 0; i < height; ++i) {
|
|
||||||
std::cout << "*";
|
|
||||||
}
|
|
||||||
std::cout << "\n";
|
|
||||||
}
|
|
||||||
};
|
|
@ -1,4 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <vector>
|
|
||||||
void show_histogram_text(const std::vector<size_t>& bins);
|
|
||||||
|
|
Двоичный файл не отображается.
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Двоичный файл не отображается.
Двоичный файл не отображается.
@ -1,38 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
|
||||||
<CodeBlocks_project_file>
|
|
||||||
<FileVersion major="1" minor="6" />
|
|
||||||
<Project>
|
|
||||||
<Option title="unittest" />
|
|
||||||
<Option pch_mode="2" />
|
|
||||||
<Option compiler="gcc" />
|
|
||||||
<Build>
|
|
||||||
<Target title="Debug">
|
|
||||||
<Option output="bin/Debug/unittest" prefix_auto="1" extension_auto="1" />
|
|
||||||
<Option object_output="obj/Debug/" />
|
|
||||||
<Option type="1" />
|
|
||||||
<Option compiler="gcc" />
|
|
||||||
<Compiler>
|
|
||||||
<Add option="-g" />
|
|
||||||
</Compiler>
|
|
||||||
</Target>
|
|
||||||
<Target title="Release">
|
|
||||||
<Option output="bin/Release/unittest" prefix_auto="1" extension_auto="1" />
|
|
||||||
<Option object_output="obj/Release/" />
|
|
||||||
<Option type="1" />
|
|
||||||
<Option compiler="gcc" />
|
|
||||||
<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,44 +0,0 @@
|
|||||||
#define DOCTEST_CONFIG_NO_MULTITHREADING
|
|
||||||
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
|
||||||
#include "doctest.h"
|
|
||||||
#include "Histogram/histogram_internal.h"
|
|
||||||
|
|
||||||
TEST_CASE("distinct positive numbers") {
|
|
||||||
double min = 0;
|
|
||||||
double max = 0;
|
|
||||||
find_minmax({1, 2}, min, max);
|
|
||||||
CHECK(min == 1);
|
|
||||||
CHECK(max == 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_CASE("empty vector") {
|
|
||||||
double min = 0;
|
|
||||||
double max = 0;
|
|
||||||
find_minmax({}, min, max);
|
|
||||||
CHECK(min == 0);
|
|
||||||
CHECK(max == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_CASE("single element vector") {
|
|
||||||
double min = 0;
|
|
||||||
double max = 0;
|
|
||||||
find_minmax({5}, min, max);
|
|
||||||
CHECK(min == 5);
|
|
||||||
CHECK(max == 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_CASE("negative numbers") {
|
|
||||||
double min = 0;
|
|
||||||
double max = 0;
|
|
||||||
find_minmax({-3, -1}, min, max);
|
|
||||||
CHECK(min == -3);
|
|
||||||
CHECK(max == -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_CASE("identical elements") {
|
|
||||||
double min = 0;
|
|
||||||
double max = 0;
|
|
||||||
find_minmax({4, 4, 4}, min, max);
|
|
||||||
CHECK(min == 4);
|
|
||||||
CHECK(max == 4);
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
# depslib dependency file v1.0
|
|
||||||
1745791868 source:c:\users\yaros_tm2sc6p\Ðàáî÷èé ñòîë\cs-lab34\histogram\histogram.cpp
|
|
||||||
"histogram.h"
|
|
||||||
<vector>
|
|
||||||
<algorithm>
|
|
||||||
|
|
||||||
1745791871 c:\users\yaros_tm2sc6p\Ðàáî÷èé ñòîë\cs-lab34\histogram\histogram.h
|
|
||||||
<vector>
|
|
||||||
|
|
||||||
1745793818 source:c:\users\yaros_tm2sc6p\Ðàáî÷èé ñòîë\cs-lab34\unittest.cpp
|
|
||||||
"doctest.h"
|
|
||||||
"Histogram/histogram_internal.h"
|
|
||||||
|
|
||||||
1745792535 c:\users\yaros_tm2sc6p\Ðàáî÷èé ñòîë\cs-lab34\doctest.h
|
|
||||||
<signal.h>
|
|
||||||
<ciso646>
|
|
||||||
<cstddef>
|
|
||||||
<ostream>
|
|
||||||
<istream>
|
|
||||||
<type_traits>
|
|
||||||
"doctest_fwd.h"
|
|
||||||
<ctime>
|
|
||||||
<cmath>
|
|
||||||
<climits>
|
|
||||||
<math.h>
|
|
||||||
<new>
|
|
||||||
<cstdio>
|
|
||||||
<cstdlib>
|
|
||||||
<cstring>
|
|
||||||
<limits>
|
|
||||||
<utility>
|
|
||||||
<fstream>
|
|
||||||
<sstream>
|
|
||||||
<iostream>
|
|
||||||
<algorithm>
|
|
||||||
<iomanip>
|
|
||||||
<vector>
|
|
||||||
<atomic>
|
|
||||||
<mutex>
|
|
||||||
<set>
|
|
||||||
<map>
|
|
||||||
<unordered_set>
|
|
||||||
<exception>
|
|
||||||
<stdexcept>
|
|
||||||
<csignal>
|
|
||||||
<cfloat>
|
|
||||||
<cctype>
|
|
||||||
<cstdint>
|
|
||||||
<string>
|
|
||||||
<sys/types.h>
|
|
||||||
<unistd.h>
|
|
||||||
<sys/sysctl.h>
|
|
||||||
<AfxWin.h>
|
|
||||||
<windows.h>
|
|
||||||
<io.h>
|
|
||||||
<sys/time.h>
|
|
||||||
<unistd.h>
|
|
||||||
|
|
||||||
1745792105 c:\users\yaros_tm2sc6p\Ðàáî÷èé ñòîë\cs-lab34\histogram\histogram_internal.h
|
|
||||||
<vector>
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
|
||||||
<CodeBlocks_layout_file>
|
|
||||||
<FileVersion major="1" minor="0" />
|
|
||||||
<ActiveTarget name="Debug" />
|
|
||||||
</CodeBlocks_layout_file>
|
|
Загрузка…
Ссылка в новой задаче