Сравнить коммиты

..

Ничего общего в коммитах. '7d912af1793a4a6912d5153961a1c864f7139e4c' и 'c8989f1ba29cf19adbec8e5ff85c1aac685c6057' имеют совершенно разные истории.

Разница между файлами не показана из-за своего большого размера Загрузить разницу

@ -1,38 +0,0 @@
#include "histogram.h"
void find_minmax(const std::vector<double>& numbers, double& min, double& max) {
min = numbers[0];
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) {
double min, max;
find_minmax(numbers, min, max);
std::vector<size_t> bins(bin_count);
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 low = min + j * bin_size;
auto high = min + (j + 1) * bin_size;
if ((low <= numbers[i]) && (numbers[i] < high))
{
bins[j]++;
found = true;
}
}
if (!found)
{
bins[bin_count - 1]++;
}
}
return bins;
}

@ -1,5 +0,0 @@
#pragma once
#include <vector>
std::vector<size_t>
make_histogram(const std::vector<double>& numbers, size_t bin_count);

@ -1,4 +0,0 @@
#pragma once
#include <vector>
void find_minmax(const std::vector<double>& numbers, double& min, double& max);

@ -1,59 +0,0 @@
#include "svg.h"
#include <iostream>
#include<string>
void svg_begin(double width, double height) {
std::cout << "<?xml version='1.0' encoding='UTF-8'?>\n";
std::cout << "<svg ";
std::cout << "width='" << width << "' ";
std::cout << "height='" << height << "' ";
std::cout << "viewBox='0 0 " << width << " " << height << "' ";
std::cout << "xmlns='http://www.w3.org/2000/svg'>\n";
}
void svg_end() {
std::cout << "</svg>\n";
}
void
svg_text(double left, double baseline, std::string text) {
std::cout << "<text x='" << left << "' y='" << baseline << "'>"<<text<<"</text>";
}
void svg_rect(double x, double y, double width, double height,std::string stroke = "black", std::string fill = "black") {
std::cout << "<rect x='"<<x<<"' y='"<<y<<"' width='"<<width<<"' height='"<<height<<"' stroke='"<<stroke<<"' fill='"<<fill<<"'/>";
}
void show_histogram_svg(const std::vector<size_t>& bins, size_t bin_count) {
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;
double mxbins = bins[0];
for (double x : bins)
{
if (x > mxbins)
mxbins = x;
}
double k;
if (mxbins > IMAGE_WIDTH-TEXT_WIDTH)
k = floor((IMAGE_WIDTH - TEXT_WIDTH) / mxbins);
else
k = 1;
svg_begin(IMAGE_WIDTH, IMAGE_HEIGHT);
double top = 0;
for (size_t bin : bins) {
int key = (10 - floor((bin) * 9 / mxbins));
std::string color = "#" +std::to_string(key)+ std::to_string(key)+ std::to_string(key);
const double bin_width = BLOCK_WIDTH * bin*k;
svg_text(TEXT_LEFT, top + TEXT_BASELINE, std::to_string(bin));
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT,color,color);
top += BIN_HEIGHT;
}
svg_end();
}

@ -1,4 +0,0 @@
#pragma once
#include <vector>
void show_histogram_svg(const std::vector<size_t>& bins, size_t bin_count);

@ -1,33 +0,0 @@
#include "text.h"
#include <iostream>
const size_t SCREEN_WIDTH = 80;
const size_t MAX_ASTERISK = SCREEN_WIDTH - 3 - 1;
void show_histogram_text(std::vector<size_t> bins, size_t bin_count) {
double mxbins = bins[0];
for (double x : bins)
{
if (x > mxbins)
mxbins = x;
}
double k;
if (mxbins > MAX_ASTERISK)
k = MAX_ASTERISK / mxbins;
else
k = 1;
for (size_t i = 0; i < bin_count; i++)
{
if (bins[i] < 10) {
std::cout << " ";
}
else if (bins[i] < 100) {
std::cout << " ";
}
std::cout << bins[i] << "|";
for (int j = 0; j < floor(bins[i] * k); j++)
{
std::cout << "*";
}
std::cout << std::endl;
}
}

@ -1,4 +0,0 @@
#pragma once
#include <vector>
void show_histogram_text(std::vector<size_t> bins, size_t bin_count);

@ -1,39 +1,81 @@
#include <vector> #include <vector>
#include <iostream> #include <iostream>
#include<cmath> #include<cmath>
#include "histogram.h"
#include "text.h"
#include "svg.h"
const size_t SCREEN_WIDTH = 80; const size_t SCREEN_WIDTH = 80;
const size_t MAX_ASTERISK = SCREEN_WIDTH - 3 - 1; const size_t MAX_ASTERISK = SCREEN_WIDTH - 3 - 1;
using namespace std; using namespace std;
struct Input { int main()
vector<double> numbers;
size_t bin_count{};
};
Input input_data()
{ {
size_t number_count; size_t number_count;
cerr << "Enter number count: ";
cin >> number_count; cin >> number_count;
Input in; vector<double> numbers(number_count);
in.numbers.resize(number_count);
for (size_t i = 0; i < number_count; i++) for (int i = 0; i < number_count; i++)
{ {
cin >> in.numbers[i]; cin >> numbers[i];
} }
double min = numbers[0];
double max = numbers[0];
for (double x : numbers)
{
if (x < min)
min = x;
else if (x > max)
max = x;
}
size_t bin_count=3;
vector<size_t> bins(bin_count);
double bin_size = (max - min) / bin_count;
for (size_t i = 0; i < number_count; i++)
{
bool found = false;
for (size_t j = 0; (j < bin_count - 1) && !found; j++)
{
auto low = min + j * bin_size;
auto high = min + (j + 1) * bin_size;
if ((low <= numbers[i]) && (numbers[i] < high))
{
bins[j]++;
found = true;
}
}
if (!found)
{
bins[bin_count - 1]++;
}
}
cin >> in.bin_count; double mxbins = bins[0];
for (double x : bins)
{
if (x > mxbins)
mxbins = x;
}
double k;
return in; if (mxbins > MAX_ASTERISK)
k = MAX_ASTERISK / mxbins;
else
k = 1;
for (size_t i = 0; i < bin_count; i++)
{
if (bins[i] < 10) {
cout << " ";
}
else if (bins[i] < 100) {
cout << " ";
} }
cout << bins[i] << "|";
int main() for (int j = 0; j < floor(bins[i] * k); j++)
{ {
Input in = input_data(); cout << "*";
vector <size_t> bins = make_histogram(in.numbers, in.bin_count); }
show_histogram_svg(bins, in.bin_count);
cout << endl;
}
} }

@ -127,17 +127,8 @@
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="histogram.cpp" />
<ClCompile Include="svg.cpp" />
<ClCompile Include="text.cpp" />
<ClCompile Include="vector.cpp" /> <ClCompile Include="vector.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ClInclude Include="histogram.h" />
<ClInclude Include="histogram_internal.h" />
<ClInclude Include="svg.h" />
<ClInclude Include="text.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>

@ -18,28 +18,5 @@
<ClCompile Include="vector.cpp"> <ClCompile Include="vector.cpp">
<Filter>Исходные файлы</Filter> <Filter>Исходные файлы</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="histogram.cpp">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="text.cpp">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="svg.cpp">
<Filter>Исходные файлы</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="histogram.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="text.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="histogram_internal.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="svg.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -1,7 +0,0 @@
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
QyNTUxOQAAACAMdZJ6jcrCTG4zN60ikNurnykEEOGpX9wjEHifeyX64wAAAJCTOx1fkzsd
XwAAAAtzc2gtZWQyNTUxOQAAACAMdZJ6jcrCTG4zN60ikNurnykEEOGpX9wjEHifeyX64w
AAAECDxICPuo/qkgxFfhB8sMFCW719N0gZe8TuxBWg+RlbhAx1knqNysJMbjM3rSKQ26uf
KQQQ4alf3CMQeJ97JfrjAAAAC2dsYWRtQE1heGdsAQI=
-----END OPENSSH PRIVATE KEY-----

@ -1 +0,0 @@
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAx1knqNysJMbjM3rSKQ26ufKQQQ4alf3CMQeJ97Jfrj gladm@Maxgl
Загрузка…
Отмена
Сохранить