commit 70f6892eb5d61e75dd83fbe9d6fcfe67788afe28 Author: SukhotinMD Date: Mon May 26 09:56:24 2025 +0300 Lab034: commit 1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2282dd4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +ProgUit Lab1.vcxproj +ProgUit Lab1.vcxproj.filters +ProgUit Lab1.vcxproj.user +/ARM64 \ No newline at end of file diff --git a/.gitignore.txt b/.gitignore.txt new file mode 100644 index 0000000..2282dd4 --- /dev/null +++ b/.gitignore.txt @@ -0,0 +1,4 @@ +ProgUit Lab1.vcxproj +ProgUit Lab1.vcxproj.filters +ProgUit Lab1.vcxproj.user +/ARM64 \ No newline at end of file diff --git a/ProgUit Lab1.sln b/ProgUit Lab1.sln new file mode 100644 index 0000000..1778f2e --- /dev/null +++ b/ProgUit Lab1.sln @@ -0,0 +1,37 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.13.35818.85 d17.13 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ProgUit Lab1", "ProgUit Lab1\ProgUit Lab1.vcxproj", "{41E87DE9-8DF4-41BE-B56C-36C601839EC4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM64 = Debug|ARM64 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|ARM64 = Release|ARM64 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {41E87DE9-8DF4-41BE-B56C-36C601839EC4}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {41E87DE9-8DF4-41BE-B56C-36C601839EC4}.Debug|ARM64.Build.0 = Debug|ARM64 + {41E87DE9-8DF4-41BE-B56C-36C601839EC4}.Debug|x64.ActiveCfg = Debug|x64 + {41E87DE9-8DF4-41BE-B56C-36C601839EC4}.Debug|x64.Build.0 = Debug|x64 + {41E87DE9-8DF4-41BE-B56C-36C601839EC4}.Debug|x86.ActiveCfg = Debug|Win32 + {41E87DE9-8DF4-41BE-B56C-36C601839EC4}.Debug|x86.Build.0 = Debug|Win32 + {41E87DE9-8DF4-41BE-B56C-36C601839EC4}.Release|ARM64.ActiveCfg = Release|ARM64 + {41E87DE9-8DF4-41BE-B56C-36C601839EC4}.Release|ARM64.Build.0 = Release|ARM64 + {41E87DE9-8DF4-41BE-B56C-36C601839EC4}.Release|x64.ActiveCfg = Release|x64 + {41E87DE9-8DF4-41BE-B56C-36C601839EC4}.Release|x64.Build.0 = Release|x64 + {41E87DE9-8DF4-41BE-B56C-36C601839EC4}.Release|x86.ActiveCfg = Release|Win32 + {41E87DE9-8DF4-41BE-B56C-36C601839EC4}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A6689844-BF3B-4F55-B9DF-6EC92110215A} + EndGlobalSection +EndGlobal diff --git a/ProgUit Lab1/ProgUit Lab1.cpp b/ProgUit Lab1/ProgUit Lab1.cpp new file mode 100644 index 0000000..7abd4c6 --- /dev/null +++ b/ProgUit Lab1/ProgUit Lab1.cpp @@ -0,0 +1,118 @@ +#include +#include + +using namespace std; + + +int main() +{ + // Объявление переменных + size_t number_count; + vector numbers; + size_t bin_count; + + const size_t SCREEN_WIDTH = 80; + const size_t MAX_ASTERISK = SCREEN_WIDTH - 3 - 1; + + size_t User_Diagram; + + // Ввод переменных + + cerr << "Enter number count: " << endl; + cin >> number_count; + + numbers.resize(number_count); + + cerr << "Enter numbers: " << endl; + + for (int i = 0; i < number_count; i++) { + cin >> numbers[i]; + + } + + cerr << "Enter bin count: " << endl; + cin >> bin_count; + + + // Объявление перменных промежуточных/вывода + + vector bins(bin_count); + double max_in_numbers = *(max_element(begin(numbers), end(numbers))); + double min_in_numbers = *(min_element(begin(numbers), end(numbers))); + + + double bin_size = (max_in_numbers - min_in_numbers) / bin_count; + + int max_in_bins = 0; + + + // Код + + for (size_t i = 0; i < number_count; i++) { + int to_bin = int((numbers[i]) - min_in_numbers) / bin_size; + if (to_bin >= bin_count) { + bins[to_bin - 1]++; + } + else { + bins[to_bin]++; + } + } + // Максимальное в коорзинах + for (int i = 0; i < bin_count; i++) { + if (bins[i] > max_in_bins) { + max_in_bins = bins[i]; + } + } + + + if (max_in_bins > MAX_ASTERISK) { + + for (int i = 0; i < bin_count; i++) { + if (bins[i] < 100) { + cout << " "; + } + if (bins[i] < 10) { + cout << " "; + } + size_t height = MAX_ASTERISK * (static_cast(bins[i]) / max_in_bins); + + cout << bins[i] << "|"; + + + for (int j = 0; j < height; j++) { + cout << "*"; + } + cout << endl; + } + + + } else { + // Если максимальное число среди коорзин меньше или равно 76 + for (int i = 0; i < bin_count; i++) { + if (bins[i] < 100) { + cout << " "; + } + if (bins[i] < 10) { + cout << " "; + } + + + cout << bins[i] << "|"; + for (int j = 0; j < bins[i]; j++) { + cout << "*"; + } + cout << endl; + } + + + } + + + + + + + + return 0; +} +