Индивидуальное задание
Этот коммит содержится в:
@@ -3,7 +3,7 @@
|
||||
<iostream>
|
||||
<vector>
|
||||
|
||||
1682338069 source:c:\users\admin\onedrive\Ðàáî÷èé ñòîë\lab1\main.cpp
|
||||
1685271547 source:c:\users\admin\onedrive\Ðàáî÷èé ñòîë\lab1\main.cpp
|
||||
<iostream>
|
||||
<vector>
|
||||
<cmath>
|
||||
@@ -12,6 +12,7 @@
|
||||
"text.h"
|
||||
"svg.h"
|
||||
<conio.h>
|
||||
"histogam_internal.h"
|
||||
|
||||
1682273839 c:\users\admin\onedrive\Ðàáî÷èé ñòîë\lab1\histogam.h
|
||||
<vector>
|
||||
@@ -45,5 +46,5 @@
|
||||
<string>
|
||||
"svg.h"
|
||||
|
||||
1682280301 c:\users\admin\onedrive\Ðàáî÷èé ñòîë\lab1\svg.h
|
||||
1685271547 c:\users\admin\onedrive\Ðàáî÷èé ñòîë\lab1\svg.h
|
||||
|
||||
|
||||
5
main.cpp
5
main.cpp
@@ -6,6 +6,7 @@
|
||||
#include "text.h"
|
||||
#include "svg.h"
|
||||
#include <conio.h>
|
||||
#include "histogam_internal.h"
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -35,6 +36,8 @@ int main()
|
||||
{
|
||||
Input in = input_data();
|
||||
auto bins = make_histogram(in.numbers, in.bin_count);
|
||||
show_histogram_svg(bins);
|
||||
double min, max;
|
||||
find_minmax(in.numbers,min,max);
|
||||
show_histogram_svg(bins,min,max);
|
||||
return 0;
|
||||
}
|
||||
|
||||
24
svg.cpp
24
svg.cpp
@@ -6,7 +6,17 @@
|
||||
#include "svg.h"
|
||||
using namespace std;
|
||||
|
||||
|
||||
size_t k=0;
|
||||
float
|
||||
step(size_t& k, size_t bin_count, double min,double max){
|
||||
float interval;
|
||||
double bin_size= (max-min)/bin_count;
|
||||
if (k < bin_count - 1){
|
||||
interval = min + (k + 1) * bin_size;
|
||||
k+=1;
|
||||
}
|
||||
return interval;
|
||||
}
|
||||
void
|
||||
svg_begin(double width, double height) {
|
||||
cout << "<?xml version='1.0' encoding='UTF-8'?>\n";
|
||||
@@ -31,7 +41,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, double min,double max) {
|
||||
const auto IMAGE_WIDTH = 400;
|
||||
const auto IMAGE_HEIGHT = 300;
|
||||
const auto TEXT_LEFT = 20;
|
||||
@@ -39,6 +49,7 @@ show_histogram_svg(const vector<size_t>& bins) {
|
||||
const auto TEXT_WIDTH = 50;
|
||||
const auto BIN_HEIGHT = 30;
|
||||
const auto BLOCK_WIDTH = 10;
|
||||
const auto INTER_WIDTH=30;
|
||||
double top = 0;
|
||||
double max_count = bins[0];
|
||||
for (size_t i = 0; i < bins.size(); i++) {
|
||||
@@ -48,9 +59,14 @@ show_histogram_svg(const vector<size_t>& bins) {
|
||||
svg_begin(400, 300);
|
||||
for (size_t bin : bins) {
|
||||
const double bin_width = (IMAGE_WIDTH - TEXT_WIDTH)*(bin/max_count);
|
||||
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin));
|
||||
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "blue", "#FF00FF");
|
||||
svg_text(TEXT_LEFT+INTER_WIDTH, top + TEXT_BASELINE, to_string(bin));
|
||||
svg_rect(TEXT_WIDTH+INTER_WIDTH, top, bin_width, BIN_HEIGHT, "blue", "#FF00FF");
|
||||
top += BIN_HEIGHT;
|
||||
if (bin!=bins[bins.size()-1]){
|
||||
float inter=step(k,bins.size(),min,max);
|
||||
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(inter));
|
||||
top += BIN_HEIGHT;
|
||||
}
|
||||
}
|
||||
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,double min, double max);
|
||||
|
||||
#endif // SVG_H_INCLUDED
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
# depslib dependency file v1.0
|
||||
1682273864 source:c:\users\admin\onedrive\Ðàáî÷èé ñòîë\lab1\histogam.cpp
|
||||
1682280773 source:c:\users\admin\onedrive\Ðàáî÷èé ñòîë\lab1\histogam.cpp
|
||||
<iostream>
|
||||
<vector>
|
||||
<cmath>
|
||||
"histogam.h"
|
||||
"histogam_internal.h"
|
||||
<conio.h>
|
||||
|
||||
1682273839 c:\users\admin\onedrive\Ðàáî÷èé ñòîë\lab1\histogam.h
|
||||
<vector>
|
||||
@@ -12,7 +13,7 @@
|
||||
1682273796 c:\users\admin\onedrive\Ðàáî÷èé ñòîë\lab1\histogam_internal.h
|
||||
<vector>
|
||||
|
||||
1682276727 source:c:\users\admin\onedrive\Ðàáî÷èé ñòîë\lab1\unittest.cpp
|
||||
1682276830 source:c:\users\admin\onedrive\Ðàáî÷èé ñòîë\lab1\unittest.cpp
|
||||
"doctest.h"
|
||||
"histogam_internal.h"
|
||||
<vector>
|
||||
|
||||
Ссылка в новой задаче
Block a user