diff --git a/text.cpp b/text.cpp new file mode 100644 index 0000000..fc64646 --- /dev/null +++ b/text.cpp @@ -0,0 +1,26 @@ +void +show_histogram_text(std::vector stolb, size_t bucket) { + const size_t SCREEN_WIDTH = 80; + const size_t MAX_ASTERISK = SCREEN_WIDTH - 3 - 1; + int maxlen = 0; + + for (int j = 0; j < bucket; j++) + { + if (maxlen MAX_ASTERISK) + { + if (maxlen != stolb[j]) height = MAX_ASTERISK * (static_cast (stolb[j])/maxlen); + else if (maxlen == stolb[j]) height = MAX_ASTERISK; + } + for (int i = 0; i < height; i++) std::cout << "*"; + std::cout << "\n"; + } +}