final ura
Этот коммит содержится в:
2
lab3.cbp
2
lab3.cbp
@@ -35,6 +35,8 @@
|
|||||||
<Unit filename="histogram.cpp" />
|
<Unit filename="histogram.cpp" />
|
||||||
<Unit filename="histogram.h" />
|
<Unit filename="histogram.h" />
|
||||||
<Unit filename="main.cpp" />
|
<Unit filename="main.cpp" />
|
||||||
|
<Unit filename="svg.cpp" />
|
||||||
|
<Unit filename="svg.h" />
|
||||||
<Unit filename="text.cpp" />
|
<Unit filename="text.cpp" />
|
||||||
<Unit filename="text.h" />
|
<Unit filename="text.h" />
|
||||||
<Extensions>
|
<Extensions>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# depslib dependency file v1.0
|
# depslib dependency file v1.0
|
||||||
1686350213 source:c:\users\kostello\desktop\lubs\lab03.2\main.cpp
|
1686359317 source:c:\users\kostello\desktop\lubs\lab03.2\main.cpp
|
||||||
<string>
|
<string>
|
||||||
"histogram.h"
|
"histogram.h"
|
||||||
"text.h"
|
"text.h"
|
||||||
@@ -19,11 +19,11 @@
|
|||||||
<vector>
|
<vector>
|
||||||
<iostream>
|
<iostream>
|
||||||
|
|
||||||
1686349467 c:\users\kostello\desktop\lubs\lab03.2\svg.h
|
1686357236 c:\users\kostello\desktop\lubs\lab03.2\svg.h
|
||||||
<iostream>
|
<iostream>
|
||||||
<vector>
|
<vector>
|
||||||
|
|
||||||
1686349791 source:c:\users\kostello\desktop\lubs\lab03.2\svg.cpp
|
1686357236 source:c:\users\kostello\desktop\lubs\lab03.2\svg.cpp
|
||||||
"svg.h"
|
"svg.h"
|
||||||
<math.h>
|
<math.h>
|
||||||
|
|
||||||
|
|||||||
11
main.cpp
11
main.cpp
@@ -1,5 +1,4 @@
|
|||||||
|
|
||||||
#include <string>
|
|
||||||
#include "histogram.h"
|
#include "histogram.h"
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "svg.h"
|
#include "svg.h"
|
||||||
@@ -10,7 +9,7 @@ using namespace std;
|
|||||||
struct Input {
|
struct Input {
|
||||||
vector<double> numbers;
|
vector<double> numbers;
|
||||||
size_t bin_count{};
|
size_t bin_count{};
|
||||||
// vector<string> colour;
|
vector<string> colour;
|
||||||
};
|
};
|
||||||
|
|
||||||
Input
|
Input
|
||||||
@@ -29,11 +28,11 @@ for (size_t i = 0; i < number_count; i++) {
|
|||||||
|
|
||||||
cin >> in.bin_count;
|
cin >> in.bin_count;
|
||||||
|
|
||||||
/*in.numbers.resize(in.bin_count);
|
in.colour.resize(in.bin_count+1);
|
||||||
|
|
||||||
for (size_t i = 0; i < in.bin_count; i++) {
|
for (size_t i = 0; i < in.bin_count; i++) {
|
||||||
cin >> in.colour[i];*/
|
cin >> in.colour[i];
|
||||||
|
}
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +42,7 @@ int main()
|
|||||||
{
|
{
|
||||||
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);
|
show_histogram_svg(bins, in.colour);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
10
svg.cpp
10
svg.cpp
@@ -30,7 +30,7 @@ cout << "<rect x='" << x << "' y='" << y << "' width='" << width * 3 << "' heigh
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
show_histogram_svg(const vector<size_t>& bins) {
|
show_histogram_svg(const vector<size_t>& bins, const vector<string>& colour) {
|
||||||
|
|
||||||
const auto IMAGE_WIDTH = 400;
|
const auto IMAGE_WIDTH = 400;
|
||||||
const auto IMAGE_HEIGHT = 300;
|
const auto IMAGE_HEIGHT = 300;
|
||||||
@@ -42,10 +42,10 @@ show_histogram_svg(const vector<size_t>& bins) {
|
|||||||
|
|
||||||
svg_begin(400, 300);
|
svg_begin(400, 300);
|
||||||
double top = 0;
|
double top = 0;
|
||||||
for (size_t bin : bins) {
|
for (size_t i=0; i< bins.size(); i++) {
|
||||||
const double bin_width = BLOCK_WIDTH * bin;
|
const double bin_width = BLOCK_WIDTH * bins[i];
|
||||||
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin));
|
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bins[i]));
|
||||||
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "red", "#ffeeee");
|
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "red", colour[i]);
|
||||||
top += BIN_HEIGHT;
|
top += BIN_HEIGHT;
|
||||||
}
|
}
|
||||||
svg_end();
|
svg_end();
|
||||||
|
|||||||
3
svg.h
3
svg.h
@@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
void show_histogram_svg(const std::vector<size_t>& bins);
|
void show_histogram_svg(const std::vector<size_t>& bins, const std::vector<std::string>& colour);
|
||||||
|
|
||||||
#endif // SVG_H_INCLUDED
|
#endif // SVG_H_INCLUDED
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user