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