commit 260247b455a7b6acd5baf847efdfb91dff58c172 Author: TekotovaVA Date: Sun May 14 20:31:56 2023 +0300 исходный вид лабораторной diff --git a/cs-lab34.cpp b/cs-lab34.cpp new file mode 100644 index 0000000..2afad2d --- /dev/null +++ b/cs-lab34.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 diff --git a/cs-lab34.sln b/cs-lab34.sln new file mode 100644 index 0000000..b1770d1 --- /dev/null +++ b/cs-lab34.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32825.248 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cs-lab34", "cs-lab34.vcxproj", "{888A12B8-028E-418D-A847-9C86D672CB87}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {888A12B8-028E-418D-A847-9C86D672CB87}.Debug|x64.ActiveCfg = Debug|x64 + {888A12B8-028E-418D-A847-9C86D672CB87}.Debug|x64.Build.0 = Debug|x64 + {888A12B8-028E-418D-A847-9C86D672CB87}.Debug|x86.ActiveCfg = Debug|Win32 + {888A12B8-028E-418D-A847-9C86D672CB87}.Debug|x86.Build.0 = Debug|Win32 + {888A12B8-028E-418D-A847-9C86D672CB87}.Release|x64.ActiveCfg = Release|x64 + {888A12B8-028E-418D-A847-9C86D672CB87}.Release|x64.Build.0 = Release|x64 + {888A12B8-028E-418D-A847-9C86D672CB87}.Release|x86.ActiveCfg = Release|Win32 + {888A12B8-028E-418D-A847-9C86D672CB87}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {13693958-13C1-4389-8A8F-AB6F4C0AECCA} + EndGlobalSection +EndGlobal