код без защиты
Этот коммит содержится в:
@@ -6,6 +6,4 @@ std::vector<size_t>
|
|||||||
make_histogram(const std::vector<double>& numbers, size_t bin_count);
|
make_histogram(const std::vector<double>& numbers, size_t bin_count);
|
||||||
bool find_minmax(std::vector<double> numbers, double& minN, double& maxN);
|
bool find_minmax(std::vector<double> numbers, double& minN, double& maxN);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // HISTOGRAM_H_INCLUDED
|
#endif // HISTOGRAM_H_INCLUDED
|
||||||
|
|||||||
28
lab03.depend
28
lab03.depend
@@ -1,13 +1,13 @@
|
|||||||
# depslib dependency file v1.0
|
# depslib dependency file v1.0
|
||||||
1746452588 source:c:\users\koldinad\desktop\lab03\histogram.cpp
|
1748102935 source:c:\users\koldinad\desktop\lab03\histogram.cpp
|
||||||
"histogram.h"
|
"histogram.h"
|
||||||
<iostream>
|
<iostream>
|
||||||
<vector>
|
<vector>
|
||||||
|
|
||||||
1746451370 c:\users\koldinad\desktop\lab03\histogram.h
|
1748104048 c:\users\koldinad\desktop\lab03\histogram.h
|
||||||
<vector>
|
<vector>
|
||||||
|
|
||||||
1746452830 source:c:\users\koldinad\desktop\lab03\main.cpp
|
1748102935 source:c:\users\koldinad\desktop\lab03\main.cpp
|
||||||
<iostream>
|
<iostream>
|
||||||
<vector>
|
<vector>
|
||||||
"histogram.h"
|
"histogram.h"
|
||||||
@@ -17,16 +17,32 @@
|
|||||||
1745846054 c:\users\koldinad\desktop\lab03\text.h
|
1745846054 c:\users\koldinad\desktop\lab03\text.h
|
||||||
<vector>
|
<vector>
|
||||||
|
|
||||||
1745846055 source:c:\users\koldinad\desktop\lab03\text.cpp
|
1748102935 source:c:\users\koldinad\desktop\lab03\text.cpp
|
||||||
"text.h"
|
"text.h"
|
||||||
<iostream>
|
<iostream>
|
||||||
<vector>
|
<vector>
|
||||||
|
|
||||||
1746452588 c:\users\koldinad\desktop\lab03\svg.h
|
1748102935 c:\users\koldinad\desktop\lab03\svg.h
|
||||||
<iostream>
|
<iostream>
|
||||||
<vector>
|
<vector>
|
||||||
|
|
||||||
1746452790 source:c:\users\koldinad\desktop\lab03\svg.cpp
|
1748102935 source:c:\users\koldinad\desktop\lab03\svg.cpp
|
||||||
"svg.h"
|
"svg.h"
|
||||||
<string>
|
<string>
|
||||||
|
|
||||||
|
1746452588 source:c:\users\koldinad\desktop\lab34\histogram.cpp
|
||||||
|
"histogram.h"
|
||||||
|
<iostream>
|
||||||
|
<vector>
|
||||||
|
|
||||||
|
1746451370 c:\users\koldinad\desktop\lab34\histogram.h
|
||||||
|
<vector>
|
||||||
|
|
||||||
|
1745846055 source:c:\users\koldinad\desktop\lab34\text.cpp
|
||||||
|
"text.h"
|
||||||
|
<iostream>
|
||||||
|
<vector>
|
||||||
|
|
||||||
|
1745846054 c:\users\koldinad\desktop\lab34\text.h
|
||||||
|
<vector>
|
||||||
|
|
||||||
|
|||||||
12
main.cpp
12
main.cpp
@@ -8,7 +8,6 @@ using namespace std;
|
|||||||
struct Input{
|
struct Input{
|
||||||
vector<double> numbers;
|
vector<double> numbers;
|
||||||
size_t bin_count{};
|
size_t bin_count{};
|
||||||
size_t font_size{};
|
|
||||||
};
|
};
|
||||||
Input
|
Input
|
||||||
input_data()
|
input_data()
|
||||||
@@ -23,15 +22,6 @@ input_data()
|
|||||||
cin >> in.numbers[i];
|
cin >> in.numbers[i];
|
||||||
}
|
}
|
||||||
cin >> in.bin_count;
|
cin >> in.bin_count;
|
||||||
|
|
||||||
size_t font_size_input = 0;
|
|
||||||
while (font_size_input < 8 || font_size_input > 32) {
|
|
||||||
cerr << "Enter font size (8–32, default is 12): ";
|
|
||||||
cin >> font_size_input;
|
|
||||||
cerr << "Invalid font size. Must be between 8 and 32.\n";
|
|
||||||
}
|
|
||||||
in.font_size = font_size_input;
|
|
||||||
|
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,5 +30,5 @@ int main()
|
|||||||
size_t max_count;
|
size_t max_count;
|
||||||
auto in = input_data();
|
auto in = input_data();
|
||||||
auto bins = make_histogram(in.numbers, in.bin_count);
|
auto bins = make_histogram(in.numbers, in.bin_count);
|
||||||
show_histogram_svg(bins, in.font_size);
|
show_histogram_svg(bins);
|
||||||
}
|
}
|
||||||
|
|||||||
24
svg.cpp
24
svg.cpp
@@ -2,7 +2,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
// Ôóíêöèè âûâîäà çàãîëîâêà è îêîí÷àíèÿ SVG
|
// Функции вывода заголовка и окончания SVG
|
||||||
void
|
void
|
||||||
svg_begin(double width, double height) {
|
svg_begin(double width, double height) {
|
||||||
cout << "<?xml version='1.0' encoding='UTF-8'?>\n";
|
cout << "<?xml version='1.0' encoding='UTF-8'?>\n";
|
||||||
@@ -17,24 +17,22 @@ svg_end() {
|
|||||||
cout << "</svg>\n";
|
cout << "</svg>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
//Ïîäïèñè ê ñòîëáöàì
|
//Подписи к столбцам
|
||||||
void
|
void
|
||||||
svg_text(double left, double baseline, string text, size_t font_size) {
|
svg_text(double left, double baseline, string text) {
|
||||||
cout << "<text x='" << left << "' y='" << baseline
|
cout << "<text x='" << left << "' y='" << baseline << "'>" << text << "</text>\n";
|
||||||
<< "' font-size='" << font_size
|
|
||||||
<< "'>" << text << "</text>\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Âûâîä ïðÿìîóãîëüíèêà
|
//Вывод прямоугольника
|
||||||
void
|
void
|
||||||
svg_rect(double x, double y, double width, double height, string stroke = "black", string fill = "black") {
|
svg_rect(double x, double y, double width, double height, string stroke = "black", string fill = "black") {
|
||||||
cout << "<rect x='" << x << "' y='" << y << "' width='" << width << "' height='" << height << "' "
|
cout << "<rect x='" << x << "' y='" << y << "' width='" << width << "' height='" << height << "' "
|
||||||
<< "stroke='" << stroke << "' fill='" << fill << "' />\n";
|
<< "stroke='" << stroke << "' fill='" << fill << "' />\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
//Ãðàôè÷åñêèé âûâîä ãèñòîãðàììû
|
//Графический вывод гистограммы
|
||||||
void
|
void
|
||||||
show_histogram_svg(const vector<size_t>& bins, size_t font_size) {
|
show_histogram_svg(const vector<size_t>& bins) {
|
||||||
const auto IMAGE_WIDTH = 400;
|
const auto IMAGE_WIDTH = 400;
|
||||||
const auto IMAGE_HEIGHT = 300;
|
const auto IMAGE_HEIGHT = 300;
|
||||||
const auto TEXT_LEFT = 20;
|
const auto TEXT_LEFT = 20;
|
||||||
@@ -53,14 +51,10 @@ show_histogram_svg(const vector<size_t>& bins, size_t font_size) {
|
|||||||
for (size_t i = 0; i < bins.size(); i++) {
|
for (size_t i = 0; i < bins.size(); i++) {
|
||||||
string color = colors[i];
|
string color = colors[i];
|
||||||
const double bin_width = BLOCK_WIDTH * bins[i];
|
const double bin_width = BLOCK_WIDTH * bins[i];
|
||||||
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bins[i]), font_size); //âûâîä ïîäïèñåé
|
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bins[i])); //вывод подписей
|
||||||
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "#ACB0EC", color); //âûâîä ñòîëáöîâ
|
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "#ACB0EC", color); //вывод столбцов
|
||||||
top += BIN_HEIGHT;
|
top += BIN_HEIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
svg_end();
|
svg_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
2
svg.h
2
svg.h
@@ -3,5 +3,5 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
void show_histogram_svg(const std::vector<size_t>& bins, size_t font_size);
|
void show_histogram_svg(const std::vector<size_t>& bins);
|
||||||
#endif // SVG_H_INCLUDED
|
#endif // SVG_H_INCLUDED
|
||||||
|
|||||||
@@ -59,3 +59,63 @@
|
|||||||
1746451281 c:\users\koldinad\desktop\lab03\histogram_internal.h
|
1746451281 c:\users\koldinad\desktop\lab03\histogram_internal.h
|
||||||
<vector>
|
<vector>
|
||||||
|
|
||||||
|
1746452588 source:c:\users\koldinad\desktop\lab34\histogram.cpp
|
||||||
|
"histogram.h"
|
||||||
|
<iostream>
|
||||||
|
<vector>
|
||||||
|
|
||||||
|
1746451370 c:\users\koldinad\desktop\lab34\histogram.h
|
||||||
|
<vector>
|
||||||
|
|
||||||
|
1746451448 source:c:\users\koldinad\desktop\lab34\unittest.cpp
|
||||||
|
"doctest.h"
|
||||||
|
"histogram_internal.h"
|
||||||
|
|
||||||
|
1745844730 c:\users\koldinad\desktop\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>
|
||||||
|
|
||||||
|
1746451281 c:\users\koldinad\desktop\lab34\histogram_internal.h
|
||||||
|
<vector>
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user