добавлен ввод из произвольного потока
Этот коммит содержится в:
5
.gitignore
поставляемый
Обычный файл
5
.gitignore
поставляемый
Обычный файл
@@ -0,0 +1,5 @@
|
|||||||
|
lab34.vcxproj
|
||||||
|
lab34.vcxproj.filters
|
||||||
|
lab34.vcxproj.user
|
||||||
|
/x64
|
||||||
|
.vs/
|
||||||
@@ -3,8 +3,11 @@
|
|||||||
#include "histogram_internal.h"
|
#include "histogram_internal.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
void
|
bool
|
||||||
find_minmax(const vector<double>& numbers, double& min, double& max) {
|
find_minmax(const vector<double>& numbers, double& min, double& max) {
|
||||||
|
if (numbers.size() == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
min = numbers[0];
|
min = numbers[0];
|
||||||
max = numbers[0];
|
max = numbers[0];
|
||||||
for (auto x : numbers) {
|
for (auto x : numbers) {
|
||||||
@@ -13,6 +16,7 @@ find_minmax(const vector<double>& numbers, double& min, double& max) {
|
|||||||
if (x < min)
|
if (x < min)
|
||||||
min = x;
|
min = x;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<size_t>
|
vector<size_t>
|
||||||
|
|||||||
@@ -3,3 +3,7 @@
|
|||||||
|
|
||||||
std::vector<size_t>
|
std::vector<size_t>
|
||||||
make_histogram(const std::vector<double>& numbers, size_t bin_count);
|
make_histogram(const std::vector<double>& numbers, size_t bin_count);
|
||||||
|
bool
|
||||||
|
find_minmax(const std::vector<double>& numbers, double& min, double& max);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
void
|
bool
|
||||||
find_minmax(const std::vector<double>& numbers, double& min, double& max);
|
find_minmax(const std::vector<double>& numbers, double& min, double& max);
|
||||||
|
|
||||||
|
|||||||
13
main.cpp
13
main.cpp
@@ -5,6 +5,7 @@
|
|||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "svg.h"
|
#include "svg.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
@@ -32,18 +33,6 @@ input_data() {
|
|||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
find_minmax(const vector<double>& numbers, double& min, double& max);
|
|
||||||
|
|
||||||
vector<size_t>
|
|
||||||
make_histogram(const vector<double>& numbers, size_t bin_count);
|
|
||||||
|
|
||||||
void
|
|
||||||
show_histogram_text(vector<size_t> bins);
|
|
||||||
|
|
||||||
void
|
|
||||||
show_histogram_svg(const vector<size_t>& bins);
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
Input in = input_data();
|
Input in = input_data();
|
||||||
auto bins = make_histogram(in.numbers, in.bin_count);
|
auto bins = make_histogram(in.numbers, in.bin_count);
|
||||||
|
|||||||
6
svg.cpp
6
svg.cpp
@@ -52,9 +52,9 @@ show_histogram_svg(const vector<size_t>& bins) {
|
|||||||
|
|
||||||
if (k > 1) k = 1;
|
if (k > 1) k = 1;
|
||||||
for (size_t bin : bins) {
|
for (size_t bin : bins) {
|
||||||
const double bin_width = BLOCK_WIDTH * bin * k;
|
const double bin_width = BLOCK_WIDTH * bin;
|
||||||
svg_text(TEXT_LEFT + top, TEXT_BASELINE, to_string(bin));
|
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin));
|
||||||
svg_rect(top + 13, 3 * BLOCK_WIDTH, BIN_HEIGHT, bin_width, "black", "#87CEEB");
|
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "black", "#87CEEB");
|
||||||
top += BIN_HEIGHT;
|
top += BIN_HEIGHT;
|
||||||
}
|
}
|
||||||
svg_end();
|
svg_end();
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user