From 0bc7ff4c22d26e1af3d74170eb2303e1cbe669c2 Mon Sep 17 00:00:00 2001 From: AngelovIvan Date: Sun, 24 Sep 2023 19:22:06 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B8=D1=81=D1=85=D0=BE=D0=B4=D0=BD=D1=8B?= =?UTF-8?q?=D0=B9=20=D0=BA=D0=BE=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 main.cpp diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..1562ad7 --- /dev/null +++ b/main.cpp @@ -0,0 +1,124 @@ +#include +#include +#include +using namespace std; + +int main() +{ + size_t colls; + size_t quantity; + size_t height; + cerr << "vvedite kolichestvo chisel" << endl; + cin >> colls; + vector numbers(colls); + cerr << "vvedite massiv" << endl; + for (int i = 0; i < colls; i++) + { + cin >> numbers[i]; + } + cerr << "vvedite kolichestvo diapazonov" << endl; + cin >> quantity; + bool heightbl = false; + while (!heightbl) + { + cerr << "vvedite velichiny gistogrammy"<> height; + if (height < colls / 3 - 4 && height < 3 && height>76) + { + cerr << "vvedena nevernaya velichina gistogrammy. vvedite novoe znachenie"< maximum) + { + maximum = numbers[i]; + } + } + float low = minimum; + + float diff = (maximum - minimum) / quantity; + float high = minimum+diff; + vector count(quantity); + for (int i = 0; i < quantity; i++) + { + if (i + 1 == quantity) + { + high=maximum; + } + int sum = 0; + for (int j = 0; j < colls; j++) + { + if (numbers[j] < high && numbers[j] >= low && high!=maximum) + { + sum++; + } + if (high == maximum && numbers[j] <= high && numbers[j] >= low) + { + sum++; + } + } + count[i] = sum; + low += diff; + high += diff; + } + int maxnum = 0; + int maxcount = count[0]; + for (int i = 0; i < quantity; i++) + { + if (maxcount > count[i]) + { + maxcount = count[i]; + maxnum = i; + } + } + for (int i = 0; i < quantity; i++) + { + if (count[i] < 100) + { + cout << " "; + } + if (count[i] < 10) + { + cout << " "; + } + cout << count[i] << " | "; + if (maxcount > height) + { + count[i] = height * (static_cast(count[i]) / maxcount); + for (int j = 0; j < count[i]; j++) + { + cout << "*"; + } + cout << endl; + + } + else + { + for (int j = 0; j < count[i]; j++) + { + cout << "*"; + } + cout << endl; + } + + } + getchar(); + getchar(); + return 0; +}