Сравнить коммиты
2 Коммитов
8c826cf9d8
...
c7252e212a
| Автор | SHA1 | Дата | |
|---|---|---|---|
| c7252e212a | |||
| 3a489a685e |
20
Lab1.cbp
20
Lab1.cbp
@@ -13,7 +13,11 @@
|
|||||||
<Option compiler="gcc" />
|
<Option compiler="gcc" />
|
||||||
<Compiler>
|
<Compiler>
|
||||||
<Add option="-g" />
|
<Add option="-g" />
|
||||||
|
<Add directory="include" />
|
||||||
</Compiler>
|
</Compiler>
|
||||||
|
<Linker>
|
||||||
|
<Add option="-static-libstdc++" />
|
||||||
|
</Linker>
|
||||||
</Target>
|
</Target>
|
||||||
<Target title="Release">
|
<Target title="Release">
|
||||||
<Option output="bin/Release/Lab1" prefix_auto="1" extension_auto="1" />
|
<Option output="bin/Release/Lab1" prefix_auto="1" extension_auto="1" />
|
||||||
@@ -22,6 +26,7 @@
|
|||||||
<Option compiler="gcc" />
|
<Option compiler="gcc" />
|
||||||
<Compiler>
|
<Compiler>
|
||||||
<Add option="-O2" />
|
<Add option="-O2" />
|
||||||
|
<Add directory="include" />
|
||||||
</Compiler>
|
</Compiler>
|
||||||
<Linker>
|
<Linker>
|
||||||
<Add option="-s" />
|
<Add option="-s" />
|
||||||
@@ -32,7 +37,22 @@
|
|||||||
<Add option="-Wall" />
|
<Add option="-Wall" />
|
||||||
<Add option="-fexceptions" />
|
<Add option="-fexceptions" />
|
||||||
</Compiler>
|
</Compiler>
|
||||||
|
<Unit filename="histogram.cpp">
|
||||||
|
<Option target="Debug" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="histogram.h">
|
||||||
|
<Option target="Debug" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="histogram_internal.h">
|
||||||
|
<Option target="<{~None~}>" />
|
||||||
|
</Unit>
|
||||||
<Unit filename="main.cpp" />
|
<Unit filename="main.cpp" />
|
||||||
|
<Unit filename="text.cpp">
|
||||||
|
<Option target="Debug" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="text.h">
|
||||||
|
<Option target="Debug" />
|
||||||
|
</Unit>
|
||||||
<Extensions>
|
<Extensions>
|
||||||
<lib_finder disable_auto="1" />
|
<lib_finder disable_auto="1" />
|
||||||
</Extensions>
|
</Extensions>
|
||||||
|
|||||||
7106
doctest.h
Обычный файл
7106
doctest.h
Обычный файл
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@@ -26,7 +26,7 @@ std::vector<size_t> make_histogram(std::vector<double> numbers, size_t bin_count
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void find_minmax(std::vector<double> numbers, double& min, double& max) {
|
void find_minmax(std::vector<double> numbers, double& min, double& max) {
|
||||||
min = numbers[0];
|
min = numbers[0];
|
||||||
max = numbers[0];
|
max = numbers[0];
|
||||||
for (double number : numbers) {
|
for (double number : numbers) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
static void find_minmax(std::vector<double> numbers, double& min, double& max);
|
void find_minmax(std::vector<double> numbers, double& min, double& max);
|
||||||
std::vector<size_t> make_histogram(std::vector<double> numbers, size_t bin_count);
|
std::vector<size_t> make_histogram(std::vector<double> numbers, size_t bin_count);
|
||||||
|
|
||||||
#endif // HISTOGRAM_H_INCLUDED
|
#endif // HISTOGRAM_H_INCLUDED
|
||||||
|
|||||||
10
main.cpp
10
main.cpp
@@ -1,6 +1,7 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
#include "histogram.h"
|
#include "histogram.h"
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
|
#include "svg.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
@@ -9,12 +10,8 @@ struct Input {
|
|||||||
size_t bin_count{};
|
size_t bin_count{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Input input_data();
|
Input input_data();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -23,11 +20,6 @@ int main()
|
|||||||
show_histogram_text(bins, in.bin_count);
|
show_histogram_text(bins, in.bin_count);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Input input_data() {
|
Input input_data() {
|
||||||
Input input_struct;
|
Input input_struct;
|
||||||
size_t countOfNumbers;
|
size_t countOfNumbers;
|
||||||
|
|||||||
18
svg.cpp
Обычный файл
18
svg.cpp
Обычный файл
@@ -0,0 +1,18 @@
|
|||||||
|
#include "svg.h"
|
||||||
|
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 show_histogram_svg(const std::vector<size_t>& bins) {
|
||||||
|
svg_begin(400, 300);
|
||||||
|
svg_end();
|
||||||
|
}
|
||||||
10
svg.h
Обычный файл
10
svg.h
Обычный файл
@@ -0,0 +1,10 @@
|
|||||||
|
#ifndef SVG_H_INCLUDED
|
||||||
|
#define SVG_H_INCLUDED
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <iostream>
|
||||||
|
void svg_begin(double width, double height);
|
||||||
|
void svg_end();
|
||||||
|
void show_histogram_svg(const std::vector<size_t>& bins);
|
||||||
|
|
||||||
|
#endif // SVG_H_INCLUDED
|
||||||
41
text.cpp
Обычный файл
41
text.cpp
Обычный файл
@@ -0,0 +1,41 @@
|
|||||||
|
#include "text.h"
|
||||||
|
|
||||||
|
void show_histogram_text(std::vector<size_t> bins , size_t bin_count) {
|
||||||
|
size_t maxCount = maxBin(bins);
|
||||||
|
size_t count_stars;
|
||||||
|
for (size_t i = 0; i < bin_count; i++) {
|
||||||
|
|
||||||
|
if (bins[i] < 100) {
|
||||||
|
std::cout << " ";
|
||||||
|
}
|
||||||
|
if (bins[i] < 10) {
|
||||||
|
std::cout << " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << bins[i];
|
||||||
|
std::cout << "|";
|
||||||
|
|
||||||
|
if (maxCount > MAX_ASTERISK) {
|
||||||
|
count_stars = MAX_ASTERISK * (static_cast<double>(bins[i]) / maxCount);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
count_stars = bins[i];
|
||||||
|
}
|
||||||
|
for (size_t i2 = 0; i2 < count_stars; i2++) {
|
||||||
|
std::cout << "*";
|
||||||
|
}
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const size_t maxBin(std::vector<size_t> bins) {
|
||||||
|
size_t max = bins[0];
|
||||||
|
for (int i = 1; i < bins.size(); i++) {
|
||||||
|
if (max < bins[i]) {
|
||||||
|
max = bins[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return max;
|
||||||
|
}
|
||||||
12
text.h
Обычный файл
12
text.h
Обычный файл
@@ -0,0 +1,12 @@
|
|||||||
|
#ifndef TEXT_H_INCLUDED
|
||||||
|
#define TEXT_H_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
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);
|
||||||
|
const size_t maxBin(std::vector<size_t> bins);
|
||||||
|
#endif // TEXT_H_INCLUDED
|
||||||
Ссылка в новой задаче
Block a user