diff --git a/bin/Debug/lab01.exe b/bin/Debug/lab01.exe
index dea2e31..c59adc0 100644
Binary files a/bin/Debug/lab01.exe and b/bin/Debug/lab01.exe differ
diff --git a/bin/Debug/marks.svg b/bin/Debug/marks.svg
index e69de29..0fe6581 100644
--- a/bin/Debug/marks.svg
+++ b/bin/Debug/marks.svg
@@ -0,0 +1,3 @@
+
+
diff --git a/emptiness_width.h b/emptiness_width.h
new file mode 100644
index 0000000..7d4f8e8
--- /dev/null
+++ b/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
diff --git a/histogram.cpp b/histogram.cpp
index 2cfda1a..e168a89 100644
--- a/histogram.cpp
+++ b/histogram.cpp
@@ -1,29 +1,36 @@
-#include "histogram.h"
#include
#include
+#include "histogram.h"
using namespace std;
-void find_minmax(vector numbers, double &min, double &max)
+
+bool find_minmax(vector 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 make_histogram (vector numbers, size_t bin_count)
{
-
double min;
double max;
find_minmax (numbers, min, max);
@@ -52,4 +59,3 @@ vector make_histogram (vector numbers, size_t bin_count)
return bins;
}
-
diff --git a/histogram.h b/histogram.h
index c55d5f0..ed9e7b4 100644
--- a/histogram.h
+++ b/histogram.h
@@ -1,7 +1,8 @@
#ifndef HISTOGRAM_H_INCLUDED
#define HISTOGRAM_H_INCLUDED
#include
-using namespace std;
-vector
-make_histogram(const vector numbers, size_t bin_count);
+
+std::vector
+make_histogram(const std::vector numbers, size_t bin_count);
+
#endif // HISTOGRAM_H_INCLUDED
diff --git a/histogram_internal.h b/histogram_internal.h
index 25954d1..d28f5fc 100644
--- a/histogram_internal.h
+++ b/histogram_internal.h
@@ -1,6 +1,7 @@
#ifndef HISTOGRAM_INTERNAL_H_INCLUDED
#define HISTOGRAM_INTERNAL_H_INCLUDED
#include
-using namespace std;
-void find_minmax(vector numbers, double &min, double &max);
+
+bool find_minmax(std::vector numbers, double& min, double& max);
+
#endif // HISTOGRAM_INTERNAL_H_INCLUDED
diff --git a/lab01.depend b/lab01.depend
index aeabfee..2d35415 100644
--- a/lab01.depend
+++ b/lab01.depend
@@ -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
@@ -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
"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
-1685302238 source:c:\users\kasma\desktop\lab03\lab01\histogram.cpp
- "histogram.h"
+1685896478 source:c:\users\kasma\desktop\lab03\lab01\histogram.cpp
+ "histogram.h"
-1685881811 c:\users\kasma\desktop\lab03\lab01\svg.h
+1685896478 c:\users\kasma\desktop\lab03\lab01\svg.h
-1685881811 source:c:\users\kasma\desktop\lab03\lab01\svg.cpp
+1685896478 source:c:\users\kasma\desktop\lab03\lab01\svg.cpp
diff --git a/lab01.layout b/lab01.layout
index 8dc7ed2..75be61b 100644
--- a/lab01.layout
+++ b/lab01.layout
@@ -2,32 +2,42 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/main.cpp b/main.cpp
index ac6d23f..dde96dc 100644
--- a/main.cpp
+++ b/main.cpp
@@ -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();
diff --git a/svg.cpp b/svg.cpp
index fac3aa4..7166ed2 100644
--- a/svg.cpp
+++ b/svg.cpp
@@ -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& bins)
{
@@ -67,8 +72,8 @@ show_histogram_svg(const vector& 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;
}
diff --git a/svg.h b/svg.h
index 91d53ba..af68030 100644
--- a/svg.h
+++ b/svg.h
@@ -5,5 +5,4 @@
void
show_histogram_svg(const std::vector& bins);
-
#endif // SVG_H_INCLUDED
diff --git a/text.h b/text.h
index 2e6e5fb..bd0f200 100644
--- a/text.h
+++ b/text.h
@@ -1,4 +1,7 @@
#ifndef TEXT_H_INCLUDED
#define TEXT_H_INCLUDED
-void show_histogram_text(std::vector bins, size_t bin_count);
+
+void
+show_histogram_text(std::vector bins, size_t bin_count);
+
#endif // TEXT_H_INCLUDED