Сравнить коммиты
Ничего общего в коммитах. '6bdb705ac806a1817927ddba15704d4db2a7b0d2' и '6c71711814e5168ae3bc2ae65ff815e28a504971' имеют совершенно разные истории.
6bdb705ac8
...
6c71711814
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@ -1,72 +0,0 @@
|
|||||||
#include <vector>
|
|
||||||
#include "histogram_internal.h"
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
|
|
||||||
vector<size_t> make_histogram(const vector<double>& numbers, size_t bin_count) {
|
|
||||||
|
|
||||||
vector<size_t> bins(bin_count);
|
|
||||||
vector<size_t> binss(bin_count);
|
|
||||||
|
|
||||||
double max, min;
|
|
||||||
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]++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int max_count = bins[0];
|
|
||||||
for (size_t i = 0; i < bin_count; i++) {
|
|
||||||
if (bins[i] > max_count) {
|
|
||||||
max_count = bins[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (max_count > 76) {
|
|
||||||
|
|
||||||
for (size_t i = 0; i < bin_count; i++) {
|
|
||||||
int count = bins[i];
|
|
||||||
size_t height = 76 * (static_cast<double>(count) / max_count);
|
|
||||||
bins[i] = height;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return bins;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool find_minmax(const vector<double>& numbers, double& min, double& max) {
|
|
||||||
if (numbers.size() == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for (auto i = 0; i < numbers.size(); i++) {
|
|
||||||
if (
|
|
||||||
numbers[i] < 0
|
|
||||||
) return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
min = numbers[0];
|
|
||||||
for (auto i = 0; i < numbers.size(); i++) {
|
|
||||||
if (numbers[i] < min) {
|
|
||||||
min = numbers[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
max = numbers[0];
|
|
||||||
for (auto i = 0; i < numbers.size(); i++) {
|
|
||||||
if (numbers[i] > max) {
|
|
||||||
max = numbers[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
std::vector<size_t> make_histogram(const std::vector<double>& numbers, size_t bin_count);
|
|
||||||
void find_minmax(const std::vector<double>& numbers, double& min, double& max);
|
|
@ -1,4 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
bool find_minmax(const std::vector<double>& numbers, double& min, double& max);
|
|
@ -1,3 +0,0 @@
|
|||||||
10
|
|
||||||
3 3 4 4 4 4 4 5 5 5
|
|
||||||
3
|
|
@ -1,53 +0,0 @@
|
|||||||
#include <iostream>
|
|
||||||
#include "svg.h"
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
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 << "'>" << "</rect>";
|
|
||||||
}
|
|
||||||
|
|
||||||
void show_histogram_svg(const vector<size_t>& bins) {
|
|
||||||
const auto IMAGE_WIDTH = 400;
|
|
||||||
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;
|
|
||||||
|
|
||||||
svg_begin(400, 300);
|
|
||||||
//svg_text(20, 20, to_string(bins[0]));
|
|
||||||
//svg_rect(50, 0, bins[0] * 10, 30);
|
|
||||||
double top = 0;
|
|
||||||
for (size_t bin : bins) {
|
|
||||||
const double bin_width = BLOCK_WIDTH * bin;
|
|
||||||
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin));
|
|
||||||
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "red", "#ffeeee");
|
|
||||||
top += BIN_HEIGHT;
|
|
||||||
}
|
|
||||||
|
|
||||||
svg_end();
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
void svg_begin(double width, double height);
|
|
||||||
void svg_end();
|
|
||||||
void svg_text(double left, double baseline, std::string text);
|
|
||||||
void svg_rect(double x, double y, double width, double height, std::string stroke, std::string fill);
|
|
||||||
void show_histogram_svg(const std::vector<size_t>& bins);
|
|
@ -1,23 +0,0 @@
|
|||||||
#include <vector>
|
|
||||||
#include "text.h"
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
void show_histogram_text(vector <size_t> bins, size_t bin_count) {
|
|
||||||
|
|
||||||
for (size_t i = 0; i < bin_count; i++) {
|
|
||||||
if (bins[i] < 100) {
|
|
||||||
cout << " ";
|
|
||||||
}
|
|
||||||
if (bins[i] < 10) {
|
|
||||||
cout << " ";
|
|
||||||
}
|
|
||||||
cout << bins[i] << "|";
|
|
||||||
for (size_t j = 0; j < bins[i]; j++) {
|
|
||||||
cout << "*";
|
|
||||||
}
|
|
||||||
cout << "\n";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
|
|
||||||
void show_histogram_text(std:: vector <size_t> bins, size_t bin_count);
|
|
@ -1,19 +0,0 @@
|
|||||||
#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);
|
|
||||||
|
|
||||||
find_minmax({ 1 }, min, max);
|
|
||||||
CHECK(min == max);
|
|
||||||
CHECK(find_minmax({ -1 }, min, max) == false);
|
|
||||||
find_minmax({ 2, 2, 2, 2 }, min, max);
|
|
||||||
CHECK(min == max);
|
|
||||||
|
|
||||||
}
|
|
@ -1,139 +0,0 @@
|
|||||||
<?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>{99da5545-a03c-4cbf-acf9-36ad991cb01a}</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>
|
|
||||||
<ClCompile Include="histogram.cpp" />
|
|
||||||
<ClCompile Include="unittest.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="histogram_internal.h" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
@ -1,30 +0,0 @@
|
|||||||
<?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>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="unittest.cpp">
|
|
||||||
<Filter>Исходные файлы</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="histogram.cpp">
|
|
||||||
<Filter>Исходные файлы</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="histogram_internal.h">
|
|
||||||
<Filter>Исходные файлы</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
Загрузка…
Ссылка в новой задаче