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