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