исходный вид лабораторной
Этот коммит содержится в:
65
cs-lab34.cpp
Обычный файл
65
cs-lab34.cpp
Обычный файл
@@ -0,0 +1,65 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
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 <double> mas(num);
|
||||||
|
vector<int> 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;
|
||||||
|
}
|
||||||
31
cs-lab34.sln
Обычный файл
31
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
|
||||||
Ссылка в новой задаче
Block a user