code: вариант 5
Этот коммит содержится в:
Двоичные данные
bin/Debug/lab01.exe
Двоичные данные
bin/Debug/lab01.exe
Двоичный файл не отображается.
@@ -0,0 +1,3 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<svg width='400' height='300' viewBox='0 0 400 300' xmlns='http://www.w3.org/2000/svg'>
|
||||||
|
<rect x='210' y='0' width='140' height='30' stroke='black' fill='red' /><text x='370' y='20'>2</text><rect x='0' y='30' width='350' height='30' stroke='black' fill='red' /><text x='370' y='50'>5</text><rect x='140' y='60' width='210' height='30' stroke='black' fill='red' /><text x='370' y='80'>3</text></svg>
|
||||||
|
|||||||
|
До Ширина: | Высота: | Размер: 0 B После Ширина: | Высота: | Размер: 437 B |
10
emptiness_width.h
Обычный файл
10
emptiness_width.h
Обычный файл
@@ -0,0 +1,10 @@
|
|||||||
|
#ifndef TEXT_H_INCLUDED
|
||||||
|
#define TEXT_H_INCLUDED
|
||||||
|
|
||||||
|
size_t emptiness_width (size_t a, size_t b)
|
||||||
|
{
|
||||||
|
size_t c = a - b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // TEXT_H_INCLUDED
|
||||||
@@ -1,9 +1,16 @@
|
|||||||
#include "histogram.h"
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include "histogram.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
void find_minmax(vector<double> numbers, double &min, double &max)
|
|
||||||
|
bool find_minmax(vector<double> numbers, double& min, double& max)
|
||||||
|
{
|
||||||
|
if (numbers.empty())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
min = numbers[0];
|
min = numbers[0];
|
||||||
max = numbers[0];
|
max = numbers[0];
|
||||||
@@ -18,12 +25,12 @@ void find_minmax(vector<double> numbers, double &min, double &max)
|
|||||||
max = x;
|
max = x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<size_t> make_histogram (vector<double> numbers, size_t bin_count)
|
vector<size_t> make_histogram (vector<double> numbers, size_t bin_count)
|
||||||
{
|
{
|
||||||
|
|
||||||
double min;
|
double min;
|
||||||
double max;
|
double max;
|
||||||
find_minmax (numbers, min, max);
|
find_minmax (numbers, min, max);
|
||||||
@@ -52,4 +59,3 @@ vector<size_t> make_histogram (vector<double> numbers, size_t bin_count)
|
|||||||
|
|
||||||
return bins;
|
return bins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
#ifndef HISTOGRAM_H_INCLUDED
|
#ifndef HISTOGRAM_H_INCLUDED
|
||||||
#define HISTOGRAM_H_INCLUDED
|
#define HISTOGRAM_H_INCLUDED
|
||||||
#include <vector>
|
#include <vector>
|
||||||
using namespace std;
|
|
||||||
vector<size_t>
|
std::vector<size_t>
|
||||||
make_histogram(const vector<double> numbers, size_t bin_count);
|
make_histogram(const std::vector<double> numbers, size_t bin_count);
|
||||||
|
|
||||||
#endif // HISTOGRAM_H_INCLUDED
|
#endif // HISTOGRAM_H_INCLUDED
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#ifndef HISTOGRAM_INTERNAL_H_INCLUDED
|
#ifndef HISTOGRAM_INTERNAL_H_INCLUDED
|
||||||
#define HISTOGRAM_INTERNAL_H_INCLUDED
|
#define HISTOGRAM_INTERNAL_H_INCLUDED
|
||||||
#include <vector>
|
#include <vector>
|
||||||
using namespace std;
|
|
||||||
void find_minmax(vector<double> numbers, double &min, double &max);
|
bool find_minmax(std::vector<double> numbers, double& min, double& max);
|
||||||
|
|
||||||
#endif // HISTOGRAM_INTERNAL_H_INCLUDED
|
#endif // HISTOGRAM_INTERNAL_H_INCLUDED
|
||||||
|
|||||||
16
lab01.depend
16
lab01.depend
@@ -1,5 +1,5 @@
|
|||||||
# depslib dependency file v1.0
|
# depslib dependency file v1.0
|
||||||
1685881811 source:c:\users\kasma\desktop\lab03\lab01\main.cpp
|
1685896478 source:c:\users\kasma\desktop\lab03\lab01\main.cpp
|
||||||
<iostream>
|
<iostream>
|
||||||
<vector>
|
<vector>
|
||||||
<conio.h>
|
<conio.h>
|
||||||
@@ -7,25 +7,25 @@
|
|||||||
"text.h"
|
"text.h"
|
||||||
"svg.h"
|
"svg.h"
|
||||||
|
|
||||||
1685289785 source:c:\users\kasma\desktop\lab03\lab01\text.cpp
|
1685896478 source:c:\users\kasma\desktop\lab03\lab01\text.cpp
|
||||||
<iostream>
|
<iostream>
|
||||||
<vector>
|
<vector>
|
||||||
"text.h"
|
"text.h"
|
||||||
|
|
||||||
1685289785 c:\users\kasma\desktop\lab03\lab01\text.h
|
1685896478 c:\users\kasma\desktop\lab03\lab01\text.h
|
||||||
|
|
||||||
1685291232 c:\users\kasma\desktop\lab03\lab01\histogram.h
|
1685896478 c:\users\kasma\desktop\lab03\lab01\histogram.h
|
||||||
<vector>
|
<vector>
|
||||||
|
|
||||||
1685302238 source:c:\users\kasma\desktop\lab03\lab01\histogram.cpp
|
1685896478 source:c:\users\kasma\desktop\lab03\lab01\histogram.cpp
|
||||||
"histogram.h"
|
|
||||||
<iostream>
|
<iostream>
|
||||||
<vector>
|
<vector>
|
||||||
|
"histogram.h"
|
||||||
|
|
||||||
1685881811 c:\users\kasma\desktop\lab03\lab01\svg.h
|
1685896478 c:\users\kasma\desktop\lab03\lab01\svg.h
|
||||||
<vector>
|
<vector>
|
||||||
|
|
||||||
1685881811 source:c:\users\kasma\desktop\lab03\lab01\svg.cpp
|
1685896478 source:c:\users\kasma\desktop\lab03\lab01\svg.cpp
|
||||||
<math.h>
|
<math.h>
|
||||||
<iostream>
|
<iostream>
|
||||||
<conio.h>
|
<conio.h>
|
||||||
|
|||||||
38
lab01.layout
38
lab01.layout
@@ -2,24 +2,19 @@
|
|||||||
<CodeBlocks_layout_file>
|
<CodeBlocks_layout_file>
|
||||||
<FileVersion major="1" minor="0" />
|
<FileVersion major="1" minor="0" />
|
||||||
<ActiveTarget name="Debug" />
|
<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="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="57" topLine="0" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="svg.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
<Cursor>
|
<Cursor>
|
||||||
<Cursor1 position="0" topLine="0" />
|
<Cursor1 position="0" topLine="0" />
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
<File name="main.cpp" open="1" top="1" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
<File name="svg.cpp" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
<Cursor>
|
<Cursor>
|
||||||
<Cursor1 position="582" topLine="3" />
|
<Cursor1 position="471" topLine="0" />
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="histogram.cpp" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="278" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="text.cpp" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="57" topLine="0" />
|
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
<File name="histogram_internal.h" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
<File name="histogram_internal.h" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
@@ -27,7 +22,22 @@
|
|||||||
<Cursor1 position="0" topLine="0" />
|
<Cursor1 position="0" topLine="0" />
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</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="text.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="0" topLine="0" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="main.cpp" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="582" topLine="0" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="histogram.cpp" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="278" topLine="0" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="histogram.h" open="1" top="1" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
<Cursor>
|
<Cursor>
|
||||||
<Cursor1 position="60" topLine="0" />
|
<Cursor1 position="60" topLine="0" />
|
||||||
</Cursor>
|
</Cursor>
|
||||||
|
|||||||
5
main.cpp
5
main.cpp
@@ -4,7 +4,6 @@
|
|||||||
#include "histogram.h"
|
#include "histogram.h"
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "svg.h"
|
#include "svg.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
struct Input
|
struct Input
|
||||||
@@ -18,6 +17,7 @@ Input input_data()
|
|||||||
size_t number_count;
|
size_t number_count;
|
||||||
cerr << "Enter number count: ";
|
cerr << "Enter number count: ";
|
||||||
cin >> number_count;
|
cin >> number_count;
|
||||||
|
|
||||||
Input in;
|
Input in;
|
||||||
in.numbers.resize(number_count);
|
in.numbers.resize(number_count);
|
||||||
for (size_t i = 0; i < number_count; i++)
|
for (size_t i = 0; i < number_count; i++)
|
||||||
@@ -28,6 +28,9 @@ Input input_data()
|
|||||||
cin>> in.bin_count;
|
cin>> in.bin_count;
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
auto in = input_data();
|
auto in = input_data();
|
||||||
|
|||||||
11
svg.cpp
11
svg.cpp
@@ -6,6 +6,12 @@
|
|||||||
#include "svg.h"
|
#include "svg.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
size_t emptiness_width (size_t a, size_t b)
|
||||||
|
{
|
||||||
|
size_t c = a - b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
svg_begin(double width, double height)
|
svg_begin(double width, double height)
|
||||||
{
|
{
|
||||||
@@ -36,7 +42,6 @@ svg_rect(double x, double y, double width, double height, string stroke = "black
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
show_histogram_svg(const vector<size_t>& bins)
|
show_histogram_svg(const vector<size_t>& bins)
|
||||||
{
|
{
|
||||||
@@ -67,8 +72,8 @@ show_histogram_svg(const vector<size_t>& bins)
|
|||||||
for (size_t bin : bins)
|
for (size_t bin : bins)
|
||||||
{
|
{
|
||||||
double bin_width = (MAX_WIDTH)*(bin/max_count);
|
double bin_width = (MAX_WIDTH)*(bin/max_count);
|
||||||
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin));
|
svg_rect(emptiness_width(MAX_WIDTH, bin_width), top, bin_width, BIN_HEIGHT, BLACK, RED);
|
||||||
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, BLACK, RED);
|
svg_text(TEXT_LEFT+MAX_WIDTH, top + TEXT_BASELINE, to_string(bin));
|
||||||
top += BIN_HEIGHT;
|
top += BIN_HEIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
1
svg.h
1
svg.h
@@ -5,5 +5,4 @@
|
|||||||
void
|
void
|
||||||
show_histogram_svg(const std::vector<size_t>& bins);
|
show_histogram_svg(const std::vector<size_t>& bins);
|
||||||
|
|
||||||
|
|
||||||
#endif // SVG_H_INCLUDED
|
#endif // SVG_H_INCLUDED
|
||||||
|
|||||||
5
text.h
5
text.h
@@ -1,4 +1,7 @@
|
|||||||
#ifndef TEXT_H_INCLUDED
|
#ifndef TEXT_H_INCLUDED
|
||||||
#define TEXT_H_INCLUDED
|
#define TEXT_H_INCLUDED
|
||||||
void show_histogram_text(std::vector<size_t> bins, size_t bin_count);
|
|
||||||
|
void
|
||||||
|
show_histogram_text(std::vector<size_t> bins, size_t bin_count);
|
||||||
|
|
||||||
#endif // TEXT_H_INCLUDED
|
#endif // TEXT_H_INCLUDED
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user