From 16c544161f85f7caf75bf167c0f8e56e8d1e05ee Mon Sep 17 00:00:00 2001
From: KapitonovMikA <KapitonovMikA@mpei.ru>
Date: Mon, 20 May 2024 02:34:17 +0300
Subject: [PATCH] =?UTF-8?q?code:=20=D1=84=D0=B0=D0=B9=D0=BB=20=D1=80=D0=B5?=
 =?UTF-8?q?=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 text.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
 create mode 100644 text.cpp

diff --git a/text.cpp b/text.cpp
new file mode 100644
index 0000000..86b58fd
--- /dev/null
+++ b/text.cpp
@@ -0,0 +1,55 @@
+#include <iostream>
+#include <conio.h>
+#include <vector>
+#include <stdlib.h>
+#include "text.h"
+using namespace std;
+void
+show_histogram_text(const vector<size_t> bins, size_t bin_count){
+    const size_t MAX_ELEMENT = 76;
+    double max_count = bins[0];
+    for (size_t j=0; j < bin_count; j++){
+        if (bins[j] > max_count) {
+            max_count = bins[j];
+        }
+    }
+    vector<size_t> height(bin_count);
+    for (size_t j=0; j < bin_count; j++){
+        height[j] = MAX_ELEMENT * (bins[j]/max_count);
+    }
+
+    if (max_count > MAX_ELEMENT){
+        for  (size_t j=0; j < bin_count; j++)
+            {
+                if (bins[j] < 100) {
+                    cout << " ";
+                    if (bins[j] < 10){
+                            cout << " ";
+                    }
+                }
+                cout << bins[j] << "|";
+
+                for (size_t i=0; i < height[j]; i++){
+                        cout << "*";
+                        }
+                cout << endl;
+            }
+    }
+    else {
+        for  (size_t j=0; j < bin_count; j++)
+            {
+                if (bins[j] < 100) {
+                    cout << " ";
+                    if (bins[j] < 10){
+                            cout << " ";
+                    }
+                }
+                cout << bins[j] << "|";
+
+                for (size_t i=0; i < bins[j];i++){
+                        cout << "*";
+                        }
+                cout << endl;
+            }
+    }
+}