From 244250a4273439bb4dddefab0421af35997fc642 Mon Sep 17 00:00:00 2001 From: TekotovaVA Date: Mon, 17 Apr 2023 12:27:45 +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=B2=D0=B8=D0=B4=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D1=80=D0=BD=D0=BE=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lab3.cpp | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 lab3.cpp diff --git a/lab3.cpp b/lab3.cpp new file mode 100644 index 0000000..2afad2d --- /dev/null +++ b/lab3.cpp @@ -0,0 +1,65 @@ +#include +#include +using namespace std; + +int main() +{ + size_t num, po, i; + double max, min, m = 0, le, ri; + cout << "num="; + cin >> num; + cout << "po="; + cin >> po; + vector mas(num); + vector ch(po); + for (i = 0; i < num; i++) + { + cout << "mas [" << i << "]="; + cin >> mas[i]; + } + cout << endl; + max = mas[0]; + min = mas[0]; + for (i = 1; i < num; i++) + { + if (max < mas[i]) + max = mas[i]; + if (min > mas[i]) + min = mas[i]; + } + le = min; + ri = le + (max - min) / po; + int kol = 0; + while (kol < po - 1) + { + for (i = 0; i < num; i++) + { + if (le <= mas[i] && ri > mas[i]) + ch[kol]++; + } + if (ch[kol] > m) + m = ch[kol]; + kol++; + le = ri; + ri = le + (max - min) / po; + } + for (i = 0; i < num; i++) + { + if ((ri <= mas[i] && le < mas[i]) || (le <= mas[i] && ri > mas[i])) + ch[kol] ++; + if (ch[kol] > m) + m = ch[kol]; + } + for (i = 0; i < po; i++) + { + int d = m - ch[i]; + if (d != 0) + for (int j = 0; j < d; j++) + cout << " "; + for (size_t j = 0; j < ch[i]; j++) + cout << "*"; + cout << "|" << ch[i]; + cout << endl; + } + return 0; +} \ No newline at end of file