build: код изменен под вариант 15
Этот коммит содержится в:
@@ -50,3 +50,9 @@ vector <size_t> make_histogramm(vector<double>numbers, size_t bin_count){
|
||||
}*/
|
||||
return bins;
|
||||
}
|
||||
|
||||
void check_interval(size_t &interval){
|
||||
if (interval > 9 || interval < 2)
|
||||
interval = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
|
||||
std::vector<size_t>
|
||||
make_histogramm(std::vector<double> numbers, size_t bin_count);
|
||||
|
||||
void check_interval(size_t &interval);
|
||||
|
||||
#endif // HISTOGRAM_H_INCLUDED
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
#include <vector>
|
||||
|
||||
void find_minmax(std::vector<double> numbers, double &min, double &max);
|
||||
|
||||
void check_interval(size_t &interval);
|
||||
#endif // HISTOGRAM_INTERNAL_H_INCLUDED
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# depslib dependency file v1.0
|
||||
1682156265 source:c:\users\gmack\onedrive\đŕáî÷čé ńňîë\lab01\lab_01\histogram.cpp
|
||||
1682183565 source:c:\users\gmack\onedrive\đŕáî÷čé ńňîë\lab01\lab_01\histogram.cpp
|
||||
<math.h>
|
||||
<iostream>
|
||||
<conio.h>
|
||||
@@ -7,10 +7,10 @@
|
||||
"histogram.h"
|
||||
"histogram_internal.h"
|
||||
|
||||
1681931103 c:\users\gmack\onedrive\đŕáî÷čé ńňîë\lab01\lab_01\histogram.h
|
||||
1682184342 c:\users\gmack\onedrive\đŕáî÷čé ńňîë\lab01\lab_01\histogram.h
|
||||
<vector>
|
||||
|
||||
1682152541 source:c:\users\gmack\onedrive\đŕáî÷čé ńňîë\lab01\lab_01\main.cpp
|
||||
1682184846 source:c:\users\gmack\onedrive\đŕáî÷čé ńňîë\lab01\lab_01\main.cpp
|
||||
<math.h>
|
||||
<iostream>
|
||||
<conio.h>
|
||||
@@ -29,12 +29,12 @@
|
||||
<vector>
|
||||
"text.h"
|
||||
|
||||
1682091658 c:\users\gmack\onedrive\đŕáî÷čé ńňîë\lab01\lab_01\histogram_internal.h
|
||||
1682183685 c:\users\gmack\onedrive\đŕáî÷čé ńňîë\lab01\lab_01\histogram_internal.h
|
||||
<vector>
|
||||
|
||||
1682108195 c:\users\gmack\onedrive\đŕáî÷čé ńňîë\lab01\lab_01\svg.h
|
||||
1682183926 c:\users\gmack\onedrive\đŕáî÷čé ńňîë\lab01\lab_01\svg.h
|
||||
|
||||
1682156695 source:c:\users\gmack\onedrive\đŕáî÷čé ńňîë\lab01\lab_01\svg.cpp
|
||||
1682189679 source:c:\users\gmack\onedrive\đŕáî÷čé ńňîë\lab01\lab_01\svg.cpp
|
||||
<math.h>
|
||||
<iostream>
|
||||
<conio.h>
|
||||
|
||||
@@ -2,14 +2,24 @@
|
||||
<CodeBlocks_layout_file>
|
||||
<FileVersion major="1" minor="0" />
|
||||
<ActiveTarget name="Debug" />
|
||||
<File name="text.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="text.cpp" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="211" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="text.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="73" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="histogram.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="svg.h" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="0" topLine="0" />
|
||||
<Cursor1 position="123" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="svg.cpp" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="2180" topLine="43" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="histogram.cpp" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
@@ -17,24 +27,19 @@
|
||||
<Cursor1 position="0" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="main.cpp" open="1" top="1" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="484" topLine="3" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="svg.cpp" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="0" topLine="4" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="text.cpp" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="362" topLine="0" />
|
||||
</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="0" topLine="0" />
|
||||
<Cursor1 position="173" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="main.cpp" open="1" top="1" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="885" topLine="22" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="histogram.h" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="207" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
</CodeBlocks_layout_file>
|
||||
|
||||
10
main.cpp
10
main.cpp
@@ -10,6 +10,7 @@ using namespace std;
|
||||
struct Input {
|
||||
vector<double> numbers;
|
||||
size_t bin_count{};
|
||||
size_t interval;
|
||||
};
|
||||
|
||||
Input
|
||||
@@ -32,6 +33,13 @@ input_data(){
|
||||
int main() {
|
||||
Input in = input_data();
|
||||
auto bins = make_histogramm(in.numbers, in.bin_count);
|
||||
show_histogram_svg(bins);
|
||||
size_t interval;
|
||||
cerr << "Input interval: "; cin >> interval;
|
||||
check_interval(interval);
|
||||
if (interval == 0){
|
||||
cerr << "ERROR";
|
||||
return 0;
|
||||
}
|
||||
show_histogram_svg(bins, interval);
|
||||
return 0;
|
||||
}
|
||||
|
||||
13
svg.cpp
13
svg.cpp
@@ -31,7 +31,7 @@ void svg_rect(double x, double y, double width, double height, string colour = "
|
||||
}
|
||||
|
||||
void
|
||||
show_histogram_svg(const vector<size_t>& bins) {
|
||||
show_histogram_svg(const vector<size_t>& bins, size_t interval) {
|
||||
const auto IMAGE_WIDTH = 400;
|
||||
const auto IMAGE_HEIGHT = 300;
|
||||
const auto TEXT_LEFT = 20;
|
||||
@@ -52,5 +52,16 @@ show_histogram_svg(const vector<size_t>& bins) {
|
||||
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "blue", "#FF00FF");
|
||||
top += BIN_HEIGHT;
|
||||
}
|
||||
top+=BIN_HEIGHT;
|
||||
const size_t SPACE = 2;
|
||||
double max_width = (IMAGE_WIDTH - TEXT_WIDTH);
|
||||
const double block = max_width/max_count;
|
||||
for (size_t i = 0; i<max_count; i++){
|
||||
if (i%interval == 0){
|
||||
svg_text(TEXT_WIDTH - SPACE + block*i, top, "|");
|
||||
svg_text(TEXT_WIDTH - SPACE + block*i, top + BIN_HEIGHT, to_string(i));
|
||||
}
|
||||
}
|
||||
svg_rect(TEXT_WIDTH, top, TEXT_WIDTH - SPACE + block*max_count, BIN_HEIGHT/5);
|
||||
svg_end();
|
||||
}
|
||||
|
||||
2
svg.h
2
svg.h
@@ -2,6 +2,6 @@
|
||||
#define SVG_H_INCLUDED
|
||||
|
||||
void
|
||||
show_histogram_svg(const std::vector<size_t>& bins);
|
||||
show_histogram_svg(const std::vector<size_t>& bins, size_t interval);
|
||||
|
||||
#endif // SVG_H_INCLUDED
|
||||
|
||||
24
unittest.cpp
24
unittest.cpp
@@ -4,7 +4,7 @@
|
||||
#include "histogram_internal.h"
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
TEST_CASE("distinct positive numbers") {
|
||||
/*TEST_CASE("distinct positive numbers") {
|
||||
double min = 0;
|
||||
double max = 0;
|
||||
std::vector<double>v{1};
|
||||
@@ -14,4 +14,26 @@ TEST_CASE("distinct positive numbers") {
|
||||
CHECK(min == 1);
|
||||
CHECK(max == 2);
|
||||
CHECK(min != max);
|
||||
}*/
|
||||
|
||||
TEST_CASE("interval check"){
|
||||
size_t interval = 3;
|
||||
check_interval(interval);
|
||||
CHECK(interval != 0);
|
||||
interval = 10;
|
||||
check_interval(interval);
|
||||
CHECK(interval == 0);
|
||||
}
|
||||
|
||||
/*#define DOCTEST_CONFIG_NO_MULTITHREADING
|
||||
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
||||
#include "doctest.h"
|
||||
#include "histogram_internal.h"
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
TEST_CASE("interval check"){
|
||||
size_t interval = 3;
|
||||
bool flag = check_interval(interval);
|
||||
CHECK(flag == true);
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# depslib dependency file v1.0
|
||||
1682090965 source:c:\users\gmack\onedrive\ðàáî÷èé ñòîë\lab01\lab_01\histogram.cpp
|
||||
1682183565 source:c:\users\gmack\onedrive\ðàáî÷èé ñòîë\lab01\lab_01\histogram.cpp
|
||||
<math.h>
|
||||
<iostream>
|
||||
<conio.h>
|
||||
@@ -10,6 +10,67 @@
|
||||
1681931103 c:\users\gmack\onedrive\ðàáî÷èé ñòîë\lab01\lab_01\histogram.h
|
||||
<vector>
|
||||
|
||||
1682091658 c:\users\gmack\onedrive\ðàáî÷èé ñòîë\lab01\lab_01\histogram_internal.h
|
||||
1682183685 c:\users\gmack\onedrive\ðàáî÷èé ñòîë\lab01\lab_01\histogram_internal.h
|
||||
<vector>
|
||||
|
||||
1682182932 source:c:\users\gmack\onedrive\ðàáî÷èé ñòîë\lab01\lab_01\unittest_15.cpp
|
||||
"doctest.h"
|
||||
"histogram_internal.h"
|
||||
<vector>
|
||||
<iostream>
|
||||
|
||||
1682183802 source:c:\users\gmack\onedrive\ðàáî÷èé ñòîë\lab01\lab_01\unittest.cpp
|
||||
"doctest.h"
|
||||
"histogram_internal.h"
|
||||
<vector>
|
||||
<iostream>
|
||||
"doctest.h"
|
||||
"histogram_internal.h"
|
||||
<vector>
|
||||
<iostream>
|
||||
|
||||
1682092158 c:\users\gmack\onedrive\ðàáî÷èé ñòîë\lab01\lab_01\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>
|
||||
|
||||
|
||||
@@ -2,24 +2,24 @@
|
||||
<CodeBlocks_layout_file>
|
||||
<FileVersion major="1" minor="0" />
|
||||
<ActiveTarget name="Debug" />
|
||||
<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="0" topLine="23" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="unittest.cpp" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="414" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="histogram_internal.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="97" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="doctest.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="doctest.h" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="0" topLine="0" />
|
||||
<Cursor1 position="168296" topLine="3336" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="unittest.cpp" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="485" topLine="6" />
|
||||
</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="1542" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
</CodeBlocks_layout_file>
|
||||
|
||||
Ссылка в новой задаче
Block a user