защита
Этот коммит содержится в:
7
.gitignore
поставляемый
7
.gitignore
поставляемый
@@ -2,4 +2,11 @@
|
||||
/obj
|
||||
/*.depend
|
||||
/*.layout
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
<<<<<<< HEAD
|
||||
/unittest
|
||||
=======
|
||||
>>>>>>> origin/main
|
||||
>>>>>>> 94468310b52ddb07436e8e8a975f56bb7644ca0f
|
||||
|
||||
40
cs-lab34.cbp
Обычный файл
40
cs-lab34.cbp
Обычный файл
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6" />
|
||||
<Project>
|
||||
<Option title="cs-lab34" />
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Build>
|
||||
<Target title="Debug">
|
||||
<Option output="bin/Debug/cs-lab34" 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/cs-lab34" 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" />
|
||||
<Add option="-fexceptions" />
|
||||
</Compiler>
|
||||
<Unit filename="main.cpp" />
|
||||
<Extensions>
|
||||
<lib_finder disable_auto="1" />
|
||||
</Extensions>
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
||||
@@ -1,6 +1,14 @@
|
||||
#ifndef HISTOGRAM_INTERNAL_H_INCLUDED
|
||||
#define HISTOGRAM_INTERNAL_H_INCLUDED
|
||||
<<<<<<< HEAD
|
||||
using namespace std;
|
||||
bool find_minmax(vector<double> vec, double& min, double& max);
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
=======
|
||||
|
||||
void find_minmax(std::vector<double> vec, double& min, double& max);
|
||||
>>>>>>> origin/main
|
||||
>>>>>>> 94468310b52ddb07436e8e8a975f56bb7644ca0f
|
||||
|
||||
#endif // HISTOGRAM_INTERNAL_H_INCLUDED
|
||||
|
||||
37
main.cpp
37
main.cpp
@@ -1,37 +1,28 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include "histogram.h"
|
||||
#include "text.h"
|
||||
#include "svg.h"
|
||||
struct Input {
|
||||
vector<double> numbers;
|
||||
size_t bin_count{};
|
||||
};
|
||||
|
||||
struct Input {
|
||||
vector<double> vec;
|
||||
size_t korz{};
|
||||
};
|
||||
Input input_data() {
|
||||
Input in;
|
||||
size_t number_count;
|
||||
|
||||
cerr << "Enter the number of elements: ";
|
||||
cin >> number_count;
|
||||
|
||||
in.numbers.resize(number_count);
|
||||
|
||||
cerr << "\nEnter " << number_count << " elements:" << endl;
|
||||
for (size_t i = 0; i < number_count; i++) {
|
||||
cin >> in.numbers[i];
|
||||
}
|
||||
|
||||
cerr << "Enter the number of bins: ";
|
||||
cin >> in.bin_count;
|
||||
size_t n, korz;
|
||||
|
||||
cerr << "Number of elements: ";
|
||||
cin >> n;
|
||||
in.vec.resize(n);
|
||||
cerr << "Elements: ";
|
||||
for (size_t i = 0; i < n; i++)
|
||||
cin >> in.vec[i];
|
||||
cerr << "Enter bin count: ";
|
||||
cin >> in.korz;
|
||||
return in;
|
||||
}
|
||||
|
||||
int main() {
|
||||
auto in = input_data();
|
||||
auto bins = make_histogram(in.bin_count, in.numbers);
|
||||
auto bins = make_histogram(in.korz, in.vec);
|
||||
show_histogram_svg(bins);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
10
svg.h
10
svg.h
@@ -1,11 +1,9 @@
|
||||
#ifndef SVG_H_INCLUDED
|
||||
#define SVG_H_INCLUDED
|
||||
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <math.h>
|
||||
using namespace std;
|
||||
void show_histogram_svg(const vector<size_t>& bins);
|
||||
|
||||
#endif // SVG_H_INCLUDED
|
||||
using namespace std;
|
||||
// Declaration for SVG histogram output
|
||||
void show_histogram_svg(const vector<size_t>& bins);
|
||||
|
||||
7106
unittest/doctest.h
Обычный файл
7106
unittest/doctest.h
Обычный файл
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@@ -31,7 +31,11 @@
|
||||
<Compiler>
|
||||
<Add option="-Wall" />
|
||||
</Compiler>
|
||||
<<<<<<< HEAD
|
||||
<Unit filename="../.gitignore" />
|
||||
=======
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> 94468310b52ddb07436e8e8a975f56bb7644ca0f
|
||||
<Unit filename="../doctest.h">
|
||||
<Option target="<{~None~}>" />
|
||||
</Unit>
|
||||
@@ -42,6 +46,8 @@
|
||||
<Option target="<{~None~}>" />
|
||||
</Unit>
|
||||
<Unit filename="../unittest.cpp" />
|
||||
=======
|
||||
>>>>>>> origin/main
|
||||
<Extensions>
|
||||
<lib_finder disable_auto="1" />
|
||||
</Extensions>
|
||||
|
||||
56
unittest/unittest.cpp
Обычный файл
56
unittest/unittest.cpp
Обычный файл
@@ -0,0 +1,56 @@
|
||||
#define DOCTEST_CONFIG_NO_MULTITHREADING
|
||||
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
||||
#include "doctest.h"
|
||||
#include "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("distinct negative numbers"){
|
||||
double min = 0;
|
||||
double max = 0;
|
||||
find_minmax({-1, -2}, min, max);
|
||||
CHECK(min == -2);
|
||||
CHECK(max == -1);
|
||||
}
|
||||
TEST_CASE("vector of the same elements"){
|
||||
double min = 0;
|
||||
double max = 0;
|
||||
find_minmax({3,3,3}, min, max);
|
||||
CHECK(min == 3);
|
||||
CHECK(max == 3);
|
||||
}
|
||||
TEST_CASE("vector of one elements"){
|
||||
double min = 0;
|
||||
double max = 0;
|
||||
find_minmax({3}, min, max);
|
||||
CHECK(min == max);
|
||||
}
|
||||
TEST_CASE("mixed positive and negative numbers") {
|
||||
double min = 0;
|
||||
double max = 0;
|
||||
find_minmax({-1, 2, 0, -3, 5}, min, max);
|
||||
CHECK(min == -3);
|
||||
CHECK(max == 5);
|
||||
}
|
||||
|
||||
TEST_CASE("vector with all negative numbers") {
|
||||
double min = 0;
|
||||
double max = 0;
|
||||
find_minmax({-5, -10, -2}, min, max);
|
||||
CHECK(min == -10);
|
||||
CHECK(max == -2);
|
||||
}
|
||||
|
||||
TEST_CASE("vector with zero") {
|
||||
double min = 0;
|
||||
double max = 0;
|
||||
find_minmax({0, -1, 1}, min, max);
|
||||
CHECK(min == -1);
|
||||
CHECK(max == 1);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
# depslib dependency file v1.0
|
||||
<<<<<<< HEAD
|
||||
1748439318 source:c:\users\home\desktop\lab34\laba01\histogram.cpp
|
||||
=======
|
||||
<<<<<<< HEAD
|
||||
1748243702 source:c:\users\home\desktop\lab34\laba01\histogram.cpp
|
||||
>>>>>>> 94468310b52ddb07436e8e8a975f56bb7644ca0f
|
||||
"histogram.h"
|
||||
|
||||
1748243654 c:\users\home\desktop\lab34\laba01\histogram.h
|
||||
@@ -132,6 +137,7 @@
|
||||
<unistd.h>
|
||||
|
||||
1748439317 c:\users\u111-15\desktop\lab34\laba01\histogram_internal.h
|
||||
<<<<<<< HEAD
|
||||
|
||||
1748439318 source:c:\users\home\desktop\lab3444\laba01\histogram.cpp
|
||||
"histogram.h"
|
||||
@@ -266,4 +272,82 @@
|
||||
<unistd.h>
|
||||
|
||||
1748439318 c:\users\home\desktop\Êàòþõà\ÌÝÈ\ëàààáû\lab34\laba01\histogram_internal.h
|
||||
=======
|
||||
>>>>>>> 94468310b52ddb07436e8e8a975f56bb7644ca0f
|
||||
|
||||
1748850515 source:c:\users\home\desktop\lab3444\laba01\histogram.cpp
|
||||
"histogram.h"
|
||||
|
||||
1748850541 c:\users\home\desktop\lab3444\laba01\histogram.h
|
||||
<vector>
|
||||
<iostream>
|
||||
|
||||
1748439286 source:c:\users\home\desktop\lab3444\laba01\unittest.cpp
|
||||
"doctest.h"
|
||||
"histogram_internal.h"
|
||||
|
||||
1748430260 c:\users\home\desktop\lab3444\laba01\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>
|
||||
|
||||
1748439318 c:\users\home\desktop\lab3444\laba01\histogram_internal.h
|
||||
|
||||
1748850295 source:c:\users\home\desktop\lab3444\laba01\svg.cpp
|
||||
"svg.h"
|
||||
|
||||
1748850424 c:\users\home\desktop\lab3444\laba01\svg.h
|
||||
<iostream>
|
||||
<vector>
|
||||
<string>
|
||||
<math.h>
|
||||
|
||||
=======
|
||||
1748415920 source:c:\users\home\desktop\laba34\histogram.cpp
|
||||
"histogram.h"
|
||||
|
||||
1748415920 c:\users\home\desktop\laba34\histogram.h
|
||||
<vector>
|
||||
<iostream>
|
||||
|
||||
>>>>>>> origin/main
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<CodeBlocks_layout_file>
|
||||
<FileVersion major="1" minor="0" />
|
||||
<ActiveTarget name="Debug" />
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
<File name="..\histogram_internal.h" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
@@ -32,16 +33,40 @@
|
||||
<Cursor>
|
||||
<Cursor1 position="208" topLine="0" />
|
||||
>>>>>>> 7d31711f139c94dfcdd92d28b83842336d4ed5c1
|
||||
=======
|
||||
<File name="..\svg.cpp" open="1" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="0" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\unittest.cpp" open="1" top="1" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="858" topLine="10" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\histogram_internal.h" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="208" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\histogram.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="216" topLine="0" />
|
||||
>>>>>>> 94468310b52ddb07436e8e8a975f56bb7644ca0f
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\doctest.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<<<<<<< HEAD
|
||||
<Cursor1 position="1170" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\unittest.cpp" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="858" topLine="4" />
|
||||
=======
|
||||
<Cursor1 position="112412" topLine="2388" />
|
||||
>>>>>>> 94468310b52ddb07436e8e8a975f56bb7644ca0f
|
||||
</Cursor>
|
||||
</File>
|
||||
</CodeBlocks_layout_file>
|
||||
|
||||
Ссылка в новой задаче
Block a user