RumyantsevVA 2 лет назад
Родитель 8f65fb9de1
Сommit be3f8e965f

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичные данные
.vs/main/v17/.suo

Двоичный файл не отображается.

Двоичные данные
.vs/main/v17/Browse.VC.db

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичные данные
.vs/unittest/v17/.suo

Двоичный файл не отображается.

Двоичные данные
.vs/unittest/v17/Browse.VC.db

Двоичный файл не отображается.

@ -0,0 +1,52 @@
#include <iostream>
#include <vector>
#include "histogram.h"
//std::vector<size_t>
void
find_minmax(const std::vector<double> numbers, double& min, double& max)
{
/*/double/*/ min = numbers[0];//ïîèñê ìèí è ìàêñ
/*/ double/*/ max = numbers[0];
for (double x : numbers)
{
if (x < min)
{
min = x;
}
else if (x > max)
{
max = x;
}
}
}
std::vector<size_t>
make_histogram(const std::vector<double> numbers, size_t bin_count)
{
std::vector <size_t> bins(bin_count);
double min, max;
find_minmax(numbers, min, max);
double bin_size = (max - min) / bin_count;//ðàçìåð êîðçèíû
for (size_t i = 0; i < numbers.size(); i++)//çàïîëíåíèå
{
bool found = false;
for (size_t j = 0; (j < bin_count - 1) && !found; j++)
{
auto lo = min + j * bin_size;
auto hi = min + (j + 1) * bin_size;
if ((lo <= numbers[i]) && (numbers[i] < hi))
{
bins[j]++;
found = true;
}
}
if (!found)
{
bins[bin_count - 1]++;
}
}
return bins;
}

@ -7,3 +7,4 @@ make_histogram(const std::vector<double> numbers, size_t bin_count);
#endif // HISTOGRAM_H_INCLUDED

@ -4,7 +4,7 @@
#include "histogram.h"
#include "text.h"
#include "histogram_internal.h"
#include "svg.h"

@ -0,0 +1,117 @@
#include <math.h>
#include <iostream>
#include <conio.h>
#include <vector>
#include <string>
#include "svg.h"
using namespace std;
void
svg_begin(double width, double height)
{
cout << "<?xml version='1.0' encoding='UTF-8'?>\n";
cout << "<svg ";
cout << "width='" << width << "' ";
cout << "height='" << height << "' ";
cout << "viewBox='0 0 " << width << " " << height << "' ";
cout << "xmlns='http://www.w3.org/2000/svg'>\n";
}
void
svg_end()
{
cout << "</svg>\n";
}
void
svg_text(double left, double baseline, string text)
{
cout << "<text x='" << left << "' y='" << baseline << "'>" << text << "</text>";
}
void
svg_rect(double x, double y, double width, double height, string stroke, string fill)
{
cout << "<rect x='" << x << "' y='" << y << "' width='" << width << "' height='" << height << "' stroke='" << stroke << "' fill='" << fill << "' />";
}
void
show_histogram_svg(const vector<size_t>& bins, size_t number_count)
{
setlocale(LC_ALL, "Russian");
int noi = 0;
auto IMAGE_WIDTH = 0;
const auto IMAGE_HEIGHT = 300;
const auto TEXT_LEFT = 20;
const auto TEXT_BASELINE = 20;
const auto TEXT_WIDTH = 50;
const auto BIN_HEIGHT = 30;
const auto BLOCK_WIDTH = 10;
const auto MAX_WIDTH = IMAGE_WIDTH - TEXT_WIDTH;
//
cerr << "Ââåäèòå æåëàåìóþ øèðèíó ñòðîêè";
//cerr<<endl;
cerr << "Ó÷òèòå, ÷òî îíà äîëæíà áûòü áîëüøå 70 è ìåíüøå 800, à òàêæå";
// cerr<<endl;
cerr << "áîëåå òðåòè êîëè÷åñâà ÷èñåë, óìíîæåííûõ íà øèðèíó áëîêà .  âàøåì ñëó÷àå áîëåå " << ((number_count * BLOCK_WIDTH) / 3) << " ";
//cerr<<endl;
//cin>>IMAGE_WIDTH;
while (noi == 0)
{
cerr << " in cicle";
//cerr<<endl;
cin >> IMAGE_WIDTH;
if ((IMAGE_WIDTH < 800) && (IMAGE_WIDTH > 70) && (IMAGE_WIDTH > (number_count * BLOCK_WIDTH) / 3))
{
noi = noi + 1;
}
if (IMAGE_WIDTH > 800)
{
cerr << " ß æå ñêàçàë ìåíüøå 800. Ââåäèòå çàíîâî";
// cerr<<endl;
}
if (IMAGE_WIDTH < 70)
{
cerr << " ß æå ñêàçàë áîëüøå 70.Ââåäèòå çàíîâî";
//cerr<<endl;
}
if (IMAGE_WIDTH < (number_count * BLOCK_WIDTH) / 3)
{
cerr << " ß æå ñêàçàë áîëüøå " << (number_count * BLOCK_WIDTH) / 3 << " Ââåäèòå çàíîâî";
// cerr<<endl;
}
}
//string k;
//string m;
svg_begin(IMAGE_WIDTH, IMAGE_HEIGHT);
double top = 0; //ìàøòàáèðâîàíèå
double max_count = bins[0];
for (size_t i = 0; i < bins.size(); i++)
{
if (bins[i] > max_count)
max_count = bins[i];
}
for (size_t bin : bins)
{
const double bin_width = (IMAGE_WIDTH - TEXT_WIDTH) * (bin / max_count);
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin));
/*/
cout<<"Ââåäèòå öâåò 1 â ôîðìàòå #RRGGBB";
cin>> k;
cout<<endl;
cout<<"Ââåäèòå öâåò 2 â ôîðìàòå #RRGGBB";
cin >> m;
/*/
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "#00CCFF" /*/k/*/, "#0000FF" /*/m/*/);
top += BIN_HEIGHT;
}
svg_end();
}

@ -0,0 +1,67 @@
#include <iostream>
#include <vector>
#include "text.h"
using namespace std;
void
show_histogram_text(vector<size_t> bins, size_t bin_count)
{
size_t max_count = 0;
for (size_t i = 0; i < bin_count; i++)
{
if (max_count < bins[i])
{
max_count = bins[i];
}
}
float procent;
for (size_t i = 0; i < bin_count; i++)
{
int procent = (float)bins[i];
if (procent < 10)
{
cout << " " << procent << " | ";
}
if ((procent < 100) && (procent >= 10))
{
cout << " " << procent << " | ";
}
size_t height = 0;
if (max_count > 76)
{
size_t height = 76 * (static_cast<double>(bins[i]) / max_count);
for (size_t j = 0; j <= height; j++)
{
cout << "*";
}
}
else
{
for (size_t j = 0; j <= bins[i] - 1; j++)
{
cout << "*";
}
}
cout << endl;
}
return;
}

@ -0,0 +1,62 @@
#define DOCTEST_CONFIG_NO_MULTITHREADING
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "doctest.h"
#include "histogram_internal.h"
TEST_CASE("distinct positive numbers")
{
double min = 0;
double max = 0;
find_minmax({ 1, 2 }, min, max);
CHECK(min == 1);
CHECK(max == 2);
}
TEST_CASE("vector 1 element")
{
double min = 0;
double max = 0;
find_minmax({ 1 }, min, max);
CHECK(min == 1);
CHECK(max == 1);
}
TEST_CASE("distinct negativ numbers")
{
double min = 0;
double max = 0;
find_minmax({ -1, -2 }, min, max);
CHECK(min == -2);
CHECK(max == -1);
}
TEST_CASE("distinct positive numbers")
{
double min = 0;
double max = 0;
find_minmax({ 2, 2 }, min, max);
CHECK(min == 2);
CHECK(max == 2);
}
TEST_CASE("distinct positive numbers")
{
double min = 0;
double max = 0;
//int n =2;
std::vector<double> pustoy;
CHECK(find_minmax(pustoy, min, max) == false);
/*/
CHECK(min == -2);
CHECK(max == -1);
/*/
/*/
double min = 0;
double max = 0;
std::vector<double> numbers {};
CHECK(find_minmax(numbers, min, max) == false);
/*/
}

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33213.308
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unittest", "unittest.vcxproj", "{84936EC8-AB44-4C6C-B5B5-5E6F6337CBE0}"
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
{84936EC8-AB44-4C6C-B5B5-5E6F6337CBE0}.Debug|x64.ActiveCfg = Debug|x64
{84936EC8-AB44-4C6C-B5B5-5E6F6337CBE0}.Debug|x64.Build.0 = Debug|x64
{84936EC8-AB44-4C6C-B5B5-5E6F6337CBE0}.Debug|x86.ActiveCfg = Debug|Win32
{84936EC8-AB44-4C6C-B5B5-5E6F6337CBE0}.Debug|x86.Build.0 = Debug|Win32
{84936EC8-AB44-4C6C-B5B5-5E6F6337CBE0}.Release|x64.ActiveCfg = Release|x64
{84936EC8-AB44-4C6C-B5B5-5E6F6337CBE0}.Release|x64.Build.0 = Release|x64
{84936EC8-AB44-4C6C-B5B5-5E6F6337CBE0}.Release|x86.ActiveCfg = Release|Win32
{84936EC8-AB44-4C6C-B5B5-5E6F6337CBE0}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {658116EB-6F9F-4DD4-9BD9-DBF7E19EEE41}
EndGlobalSection
EndGlobal

@ -0,0 +1,138 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{84936ec8-ab44-4c6c-b5b5-5e6f6337cbe0}</ProjectGuid>
<RootNamespace>unittest</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared" >
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup></ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Исходные файлы">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Файлы заголовков">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Файлы ресурсов">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
</Project>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>

Двоичные данные
x64/Debug/main.obj

Двоичный файл не отображается.

Двоичные данные
x64/Debug/main.pdb

Двоичный файл не отображается.

Двоичные данные
x64/Debug/main.tlog/CL.read.1.tlog

Двоичный файл не отображается.

Двоичные данные
x64/Debug/vc143.idb

Двоичный файл не отображается.

Двоичные данные
x64/Debug/vc143.pdb

Двоичный файл не отображается.
Загрузка…
Отмена
Сохранить