From db7e3ea29bf271dc5a0cf6554e29076074eac5a5 Mon Sep 17 00:00:00 2001 From: "Alexander (AntonovichAN)" Date: Sat, 5 Oct 2024 16:15:18 +0300 Subject: [PATCH] =?UTF-8?q?code:=20=D0=BF=D1=83=D0=BD=D0=BA=D1=82=203.3=20?= =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 6 +++--- text.cpp | 8 ++++---- text.h | 3 +-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/main.cpp b/main.cpp index 5a6b998..f333476 100644 --- a/main.cpp +++ b/main.cpp @@ -34,8 +34,8 @@ Input input_data() { int main(){ Input in = input_data(); - auto bins = make_histogram(in.numbers, in.bin_count); - - show_histogram_text(bins); + show_histogram_text(bins, in.bin_count); + return 0; } + diff --git a/text.cpp b/text.cpp index bc947fc..6c85094 100644 --- a/text.cpp +++ b/text.cpp @@ -7,16 +7,16 @@ using namespace std; const size_t SCREEN_WIDTH = 80; const size_t MAX_ASTERISK = SCREEN_WIDTH - 4; -void show_histogram_text(const vector &bins){ +void show_histogram_text(vector &bins, size_t bin_count){ size_t maxbin = bins[0]; - for (size_t i=1; i < bins.size(); i++){ + for (size_t i=1; i < bin_count; i++){ if (maxbin < bins[i]){ maxbin = bins[i]; } } if (maxbin <= MAX_ASTERISK){ - for (size_t i = 0; i < bins.size(); i++) { + for (size_t i = 0; i < bin_count; i++) { cout.width(4); cout << bins[i] << "|"; for (size_t j = 0; j < bins[i]; j++) { @@ -25,7 +25,7 @@ void show_histogram_text(const vector &bins){ cout << endl; } } else { - for (size_t i = 0; i < bins.size(); i++) { + for (size_t i = 0; i < bin_count; i++) { cout.width(4); cout << bins[i] << "|"; size_t height = static_cast(MAX_ASTERISK * (static_cast(bins[i]) / maxbin)); diff --git a/text.h b/text.h index 9a3bae6..4936728 100644 --- a/text.h +++ b/text.h @@ -3,7 +3,6 @@ #include -std::vector -show_histogram_text(const std::vector & bins); +void show_histogram_text(std::vector & bins, std::size_t bin_count); #endif // TEXT_H_INCLUDED