From 33c59ab153274c502e8612793d949d9aedbe814d Mon Sep 17 00:00:00 2001 From: BezhenarAN Date: Tue, 23 Apr 2024 20:52:34 +0300 Subject: [PATCH] =?UTF-8?q?code:=D0=BF=D1=83=D0=BD=D0=BA=D1=82=204.3=20(?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5=D0=BD=D0=BE=D1=81=20=D1=84=D1=83=D0=BD?= =?UTF-8?q?=D0=BA=D1=86=D0=B8=D0=B8=20show=5Fhistogram=5Ftext=20=D0=B2=20?= =?UTF-8?q?=D1=84=D0=B0=D0=B9=D0=BB)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 60 +++----------------------------------------------------- 1 file changed, 3 insertions(+), 57 deletions(-) diff --git a/main.cpp b/main.cpp index 7eb0f81..7f736cf 100644 --- a/main.cpp +++ b/main.cpp @@ -1,10 +1,9 @@ #include #include #include "histogram.h" - +#include "text.h" using namespace std; -const size_t SCREEN_WIDTH = 80; -const size_t MAX_ASTERISK = SCREEN_WIDTH - 3 - 1; + struct Input { vector numbers; @@ -35,60 +34,7 @@ Input input_data() { } -void show_histogram_text(const vector &bins){ - size_t maxbin = bins[0]; - for (size_t i=1; i < bins.size(); i++){ - if (maxbin < bins[i]){ - maxbin = bins[i]; - } - } - if (maxbin <=MAX_ASTERISK){ - for ( size_t i=0; i < bins.size(); i++ ){ - if ((bins[i] < 1000)&&(bins[i] > 99)){ - cout << bins[i] << "|"; - for ( size_t j=0; j < bins[i]; j++ ){ - cout << "*"; - } - cout << endl; - } else if ((bins[i] < 100)&&(bins[i]>9)) { - cout << " " << bins[i] << "|"; - for ( size_t j=0; j < bins[i]; j++ ){ - cout << "*"; - } - cout << endl; - } else if ( bins[i] < 10 ){ - cout << " " << bins[i]<< "|"; - for ( size_t j=0; j < bins[i]; j++ ){ - cout << "*"; - } - cout << endl; - } - } - } else { - for (size_t i=0; i < bins.size(); i++){ - size_t heightG= MAX_ASTERISK * (static_cast(bins[i]) / maxbin); - if ((bins[i] < 1000)&&(bins[i] > 99)){ - cout << bins[i] << "|"; - for ( size_t j=0; j < heightG; j++ ){ - cout << "*"; - } - cout << endl; - } else if ((bins[i] < 100)&&(bins[i]>9)) { - cout << " " << bins[i] << "|"; - for ( size_t j=0; j < heightG; j++ ){ - cout << "*"; - } - cout << endl; - } else if ( bins[i] < 10 ){ - cout << " " << bins[i]<< "|"; - for ( size_t j=0; j < heightG; j++ ){ - cout << "*"; - } - cout << endl; - } - } - } -} + int main(){