Alice (KanishchevYA) 2 лет назад
Родитель 533ca0cdee
Сommit 471d7b9e2d

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

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="laba3" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/laba3" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/laba3" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
<Add option="-fexceptions" />
</Compiler>
<Unit filename="histogram.cpp" />
<Unit filename="histogram.h" />
<Unit filename="histogram_internal.h" />
<Unit filename="main.cpp" />
<Unit filename="svg.cpp" />
<Unit filename="svg.h" />
<Unit filename="text.cpp" />
<Unit filename="text.h" />
<Extensions>
<lib_finder disable_auto="1" />
</Extensions>
</Project>
</CodeBlocks_project_file>

@ -0,0 +1,70 @@
# depslib dependency file v1.0
1685565176 source:c:\users\Øåñòîâ Äåíèñ\desktop\laba3\histogram.cpp
"histogram.h"
<vector>
1685565442 c:\users\Øåñòîâ Äåíèñ\desktop\laba3\histogram.h
<vector>
1685567342 source:c:\users\Øåñòîâ Äåíèñ\desktop\laba3\main.cpp
<iostream>
<vector>
"histogram.h"
"text.h"
"svg.h"
1685565442 c:\users\Øåñòîâ Äåíèñ\desktop\laba3\text.h
<vector>
1685565360 c:\users\Øåñòîâ Äåíèñ\desktop\laba3\svg.h
<vector>
1685567277 source:c:\users\Øåñòîâ Äåíèñ\desktop\laba3\svg.cpp
<vector>
<iostream>
"svg.h"
1685567303 source:c:\users\Øåñòîâ Äåíèñ\desktop\laba3\text.cpp
"text.h"
<vector>
<math.h>
<iostream>
1686135241 source:c:\users\kostello\desktop\copy\bobus\histogram.cpp
"histogram.h"
<vector>
1686135241 c:\users\kostello\desktop\copy\bobus\histogram.h
<vector>
1686135241 source:c:\users\kostello\desktop\copy\bobus\main.cpp
<iostream>
<vector>
"histogram.h"
"text.h"
<conio.h>
"histogram_internal.h"
<curl/curl.h>
<sstream>
"svg.h"
1686135242 c:\users\kostello\desktop\copy\bobus\text.h
<vector>
1686135241 c:\users\kostello\desktop\copy\bobus\histogram_internal.h
<vector>
1686135242 c:\users\kostello\desktop\copy\bobus\svg.h
<vector>
1686135242 source:c:\users\kostello\desktop\copy\bobus\svg.cpp
<vector>
<iostream>
"svg.h"
1686135242 source:c:\users\kostello\desktop\copy\bobus\text.cpp
"text.h"
<vector>
<math.h>
<iostream>

@ -0,0 +1,61 @@
#include <vector>
#include <iostream>
#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) {
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;
const auto MAX_WIDTH = IMAGE_WIDTH-TEXT_WIDTH;
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));
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "red", arr[i]);
top += BIN_HEIGHT;
}
svg_end();
}

@ -0,0 +1,8 @@
#ifndef SVG_H_INCLUDED
#define SVG_H_INCLUDED
#include <vector>
void show_histogram_svg(const std::vector<size_t>& bins);
#endif // SVG_H_INCLUDED

@ -0,0 +1,28 @@
#include "text.h"
#include <vector>
#include <math.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";
}
}

@ -0,0 +1,10 @@
#ifndef TEXT_H_INCLUDED
#define TEXT_H_INCLUDED
#include <vector>
void show_histogram_text(std::vector <size_t> bins, size_t bin_count);
#endif // TEXT_H_INCLUDED

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="unittest" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/unittest" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/unittest" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
</Compiler>
<Unit filename="doctest.h" />
<Unit filename="histogram.cpp" />
<Unit filename="unittest.cpp" />
<Extensions />
</Project>
</CodeBlocks_project_file>

@ -0,0 +1,60 @@
# depslib dependency file v1.0
1685565360 source:c:\users\Øåñòîâ Äåíèñ\desktop\laba3\unittest.cpp
"doctest.h"
"histogram_internal.h"
1685565129 c:\users\Øåñòîâ Äåíèñ\desktop\laba3\doctest.h
<signal.h>
<ciso646>
<cstddef>
<ostream>
<istream>
<type_traits>
"doctest_fwd.h"
<ctime>
<cmath>
<climits>
<math.h>
<new>
<cstdio>
<cstdlib>
<cstring>
<limits>
<utility>
<fstream>
<sstream>
<iostream>
<algorithm>
<iomanip>
<vector>
<atomic>
<mutex>
<set>
<map>
<unordered_set>
<exception>
<stdexcept>
<csignal>
<cfloat>
<cctype>
<cstdint>
<string>
<sys/types.h>
<unistd.h>
<sys/sysctl.h>
<AfxWin.h>
<windows.h>
<io.h>
<sys/time.h>
<unistd.h>
1685565176 c:\users\Øåñòîâ Äåíèñ\desktop\laba3\histogram_internal.h
<vector>
1685565176 source:c:\users\Øåñòîâ Äåíèñ\desktop\laba3\histogram.cpp
"histogram.h"
<vector>
1686126750 c:\users\Øåñòîâ Äåíèñ\desktop\laba3\histogram.h
<vector>
Загрузка…
Отмена
Сохранить