Alice (KasimovAM) 2 лет назад
Родитель 069c2a8bf5
Сommit 79699e18c7

Двоичные данные
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

@ -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,29 +1,36 @@
#include "histogram.h"
#include <iostream>
#include <vector>
#include "histogram.h"
using namespace std;
void find_minmax(vector<double> numbers, double &min, double &max)
bool find_minmax(vector<double> numbers, double& min, double& max)
{
min = numbers[0];
max = numbers[0];
for (double x : numbers)
if (numbers.empty())
{
if (x < min)
{
min = x;
}
else if (x > max)
return true;
}
else
{
min = numbers[0];
max = numbers[0];
for (double x : numbers)
{
max = x;
if (x < min)
{
min = x;
}
else if (x > max)
{
max = x;
}
}
}
return;
return false;
}
vector<size_t> make_histogram (vector<double> numbers, size_t bin_count)
{
double min;
double max;
find_minmax (numbers, min, max);
@ -52,4 +59,3 @@ vector<size_t> make_histogram (vector<double> numbers, size_t bin_count)
return bins;
}

@ -1,7 +1,8 @@
#ifndef HISTOGRAM_H_INCLUDED
#define HISTOGRAM_H_INCLUDED
#include <vector>
using namespace std;
vector<size_t>
make_histogram(const vector<double> numbers, size_t bin_count);
std::vector<size_t>
make_histogram(const std::vector<double> numbers, size_t bin_count);
#endif // HISTOGRAM_H_INCLUDED

@ -1,6 +1,7 @@
#ifndef HISTOGRAM_INTERNAL_H_INCLUDED
#define HISTOGRAM_INTERNAL_H_INCLUDED
#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

@ -1,5 +1,5 @@
# 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>
<vector>
<conio.h>
@ -7,25 +7,25 @@
"text.h"
"svg.h"
1685289785 source:c:\users\kasma\desktop\lab03\lab01\text.cpp
1685896478 source:c:\users\kasma\desktop\lab03\lab01\text.cpp
<iostream>
<vector>
"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>
1685302238 source:c:\users\kasma\desktop\lab03\lab01\histogram.cpp
"histogram.h"
1685896478 source:c:\users\kasma\desktop\lab03\lab01\histogram.cpp
<iostream>
<vector>
"histogram.h"
1685881811 c:\users\kasma\desktop\lab03\lab01\svg.h
1685896478 c:\users\kasma\desktop\lab03\lab01\svg.h
<vector>
1685881811 source:c:\users\kasma\desktop\lab03\lab01\svg.cpp
1685896478 source:c:\users\kasma\desktop\lab03\lab01\svg.cpp
<math.h>
<iostream>
<conio.h>

@ -2,32 +2,42 @@
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<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="0" topLine="0" />
<Cursor1 position="57" topLine="0" />
</Cursor>
</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.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="582" topLine="3" />
<Cursor1 position="0" 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">
<File name="svg.cpp" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="278" topLine="0" />
<Cursor1 position="471" 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">
<File name="histogram_internal.h" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="57" topLine="0" />
<Cursor1 position="0" topLine="0" />
</Cursor>
</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="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="histogram.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<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>
<Cursor1 position="60" topLine="0" />
</Cursor>

@ -4,7 +4,6 @@
#include "histogram.h"
#include "text.h"
#include "svg.h"
using namespace std;
struct Input
@ -16,18 +15,22 @@ struct Input
Input input_data()
{
size_t number_count;
cerr<<"Enter number count: ";
cerr << "Enter number count: ";
cin >> number_count;
Input in;
in.numbers.resize(number_count);
for (size_t i =0; i < number_count; i++)
for (size_t i = 0; i < number_count; i++)
{
cin >> in.numbers[i];
}
cerr<< "Enter bin count: ";
cin >> in.bin_count;
cerr << "Enter bin count: ";
cin>> in.bin_count;
return in;
}
int main()
{
auto in = input_data();

@ -6,6 +6,12 @@
#include "svg.h"
using namespace std;
size_t emptiness_width (size_t a, size_t b)
{
size_t c = a - b;
return c;
}
void
svg_begin(double width, double height)
{
@ -36,7 +42,6 @@ svg_rect(double x, double y, double width, double height, string stroke = "black
}
void
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)
{
double bin_width = (MAX_WIDTH)*(bin/max_count);
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin));
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, BLACK, RED);
svg_rect(emptiness_width(MAX_WIDTH, bin_width), top, bin_width, BIN_HEIGHT, BLACK, RED);
svg_text(TEXT_LEFT+MAX_WIDTH, top + TEXT_BASELINE, to_string(bin));
top += BIN_HEIGHT;
}

@ -5,5 +5,4 @@
void
show_histogram_svg(const std::vector<size_t>& bins);
#endif // SVG_H_INCLUDED

@ -1,4 +1,7 @@
#ifndef 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

Загрузка…
Отмена
Сохранить