Сравнить коммиты
8 Коммитов
3f2a04f00d
...
89f5920b56
Автор | SHA1 | Дата |
---|---|---|
|
89f5920b56 | 2 лет назад |
|
487e87fa26 | 2 лет назад |
|
c88ad95f59 | 2 лет назад |
|
3951d00019 | 2 лет назад |
|
b3538a0dc1 | 2 лет назад |
|
9a80d84a7a | 2 лет назад |
|
2bc5c10c5a | 2 лет назад |
|
f1d0f2c795 | 2 лет назад |
@ -0,0 +1,4 @@
|
|||||||
|
/bin
|
||||||
|
/obj
|
||||||
|
/1.layout
|
||||||
|
/curl
|
@ -0,0 +1,104 @@
|
|||||||
|
# depslib dependency file v1.0
|
||||||
|
1677500178 source:l:\i êóðñ\À-2-22\Êîíîâàëîâà\1\main.cpp
|
||||||
|
<iostream>
|
||||||
|
<vector>
|
||||||
|
|
||||||
|
1681133505 source:c:\users\u111-09\desktop\1\main.cpp
|
||||||
|
<iostream>
|
||||||
|
<vector>
|
||||||
|
"histogram.h"
|
||||||
|
|
||||||
|
1681133536 source:c:\users\u111-09\desktop\1\histogram.cpp
|
||||||
|
<iostream>
|
||||||
|
<vector>
|
||||||
|
"histogram.h"
|
||||||
|
|
||||||
|
1681131906 c:\users\u111-09\desktop\1\histogram.h
|
||||||
|
<vector>
|
||||||
|
|
||||||
|
1681132321 source:c:\users\u111-09\desktop\1\text.cpp
|
||||||
|
<iostream>
|
||||||
|
<vector>
|
||||||
|
|
||||||
|
1684764299 source:c:\users\79156\desktop\3\main.cpp
|
||||||
|
<iostream>
|
||||||
|
<vector>
|
||||||
|
<cmath>
|
||||||
|
<windows.h>
|
||||||
|
"histogram.h"
|
||||||
|
"svg.h"
|
||||||
|
<curl/curl.h>
|
||||||
|
<sstream>
|
||||||
|
<string>
|
||||||
|
|
||||||
|
1681131908 c:\users\79156\desktop\3\histogram.h
|
||||||
|
<vector>
|
||||||
|
|
||||||
|
1682253694 c:\users\79156\desktop\3\svg.h
|
||||||
|
<vector>
|
||||||
|
|
||||||
|
1682333182 source:c:\users\79156\desktop\3\histogram.cpp
|
||||||
|
<iostream>
|
||||||
|
<vector>
|
||||||
|
<windows.h>
|
||||||
|
"histogram.h"
|
||||||
|
|
||||||
|
1682263714 c:\users\79156\desktop\3\histogram_internal.h
|
||||||
|
<vector>
|
||||||
|
|
||||||
|
1684753247 source:c:\users\79156\desktop\3\svg.cpp
|
||||||
|
<math.h>
|
||||||
|
<iostream>
|
||||||
|
<conio.h>
|
||||||
|
<vector>
|
||||||
|
<string>
|
||||||
|
"svg.h"
|
||||||
|
|
||||||
|
1684137360 c:\users\79156\desktop\3\curl\include\curl\curl.h
|
||||||
|
"curlver.h"
|
||||||
|
"system.h"
|
||||||
|
<stdio.h>
|
||||||
|
<limits.h>
|
||||||
|
<osreldate.h>
|
||||||
|
<sys/types.h>
|
||||||
|
<time.h>
|
||||||
|
<winsock2.h>
|
||||||
|
<ws2tcpip.h>
|
||||||
|
<sys/select.h>
|
||||||
|
<sys/socket.h>
|
||||||
|
<sys/time.h>
|
||||||
|
"easy.h"
|
||||||
|
"multi.h"
|
||||||
|
"urlapi.h"
|
||||||
|
"options.h"
|
||||||
|
"header.h"
|
||||||
|
"websockets.h"
|
||||||
|
"typecheck-gcc.h"
|
||||||
|
|
||||||
|
1684292872 c:\users\79156\desktop\3\curl\include\curl\curlver.h
|
||||||
|
|
||||||
|
1684137360 c:\users\79156\desktop\3\curl\include\curl\system.h
|
||||||
|
<ConditionalMacros.h>
|
||||||
|
<winsock2.h>
|
||||||
|
<windows.h>
|
||||||
|
<ws2tcpip.h>
|
||||||
|
<sys/types.h>
|
||||||
|
<sys/socket.h>
|
||||||
|
<sys/poll.h>
|
||||||
|
|
||||||
|
1684137360 c:\users\79156\desktop\3\curl\include\curl\easy.h
|
||||||
|
|
||||||
|
1684137360 c:\users\79156\desktop\3\curl\include\curl\multi.h
|
||||||
|
"curl.h"
|
||||||
|
|
||||||
|
1684137360 c:\users\79156\desktop\3\curl\include\curl\urlapi.h
|
||||||
|
"curl.h"
|
||||||
|
|
||||||
|
1684137360 c:\users\79156\desktop\3\curl\include\curl\options.h
|
||||||
|
|
||||||
|
1684137360 c:\users\79156\desktop\3\curl\include\curl\header.h
|
||||||
|
|
||||||
|
1684137360 c:\users\79156\desktop\3\curl\include\curl\websockets.h
|
||||||
|
|
||||||
|
1684137360 c:\users\79156\desktop\3\curl\include\curl\typecheck-gcc.h
|
||||||
|
|
@ -0,0 +1,62 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
#include <windows.h>
|
||||||
|
//#include "histogram_internal.h"
|
||||||
|
#include "histogram.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
find_minmax(vector<double> numbers, double& min, double& max)
|
||||||
|
{
|
||||||
|
if(numbers.size() == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
min = numbers[0];
|
||||||
|
max = numbers[0];
|
||||||
|
size_t number_count = numbers.size();
|
||||||
|
for (size_t i = 1; i < number_count; i++)
|
||||||
|
{
|
||||||
|
if (numbers[i] < min)
|
||||||
|
{
|
||||||
|
min = numbers[i];
|
||||||
|
}
|
||||||
|
else if (numbers[i] > max)
|
||||||
|
{
|
||||||
|
max = numbers[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<size_t>
|
||||||
|
make_histogram(const vector<double>& numbers, size_t bin_count)
|
||||||
|
{
|
||||||
|
|
||||||
|
double min, max;
|
||||||
|
vector<size_t> bins(bin_count);
|
||||||
|
find_minmax(numbers, min, max);
|
||||||
|
double bin_size = (max - min) / bin_count;
|
||||||
|
size_t number_count = numbers.size();
|
||||||
|
|
||||||
|
for (size_t i = 0; i < number_count; 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;
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
#ifndef HISTOGRAM_H_INCLUDED
|
||||||
|
#define HISTOGRAM_H_INCLUDED
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
std::vector<size_t>
|
||||||
|
make_histogram(const std::vector<double>& numbers, size_t bin_count);
|
||||||
|
|
||||||
|
#endif // HISTOGRAM_H_INCLUDED
|
||||||
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
|||||||
|
#ifndef HISTOGRAM_INTERNAL_H_INCLUDED
|
||||||
|
#define HISTOGRAM_INTERNAL_H_INCLUDED
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
bool
|
||||||
|
find_minmax(std::vector<double> numbers, double& min, double& max);
|
||||||
|
|
||||||
|
#endif // HISTOGRAM_INTERNAL_H_INCLUDED
|
@ -1,51 +1,89 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cmath>
|
#include <conio.h>
|
||||||
#include <windows.h>
|
|
||||||
#include "histogram.h"
|
#include "histogram.h"
|
||||||
|
#include "text.h"
|
||||||
#include "svg.h"
|
#include "svg.h"
|
||||||
|
#include <curl/curl.h>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
struct Input
|
struct Input
|
||||||
{
|
{
|
||||||
vector<double> numbers;
|
vector<double> numbers;
|
||||||
size_t bin_count{};
|
size_t bin_count{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Input
|
Input
|
||||||
input_data()
|
input_data(istream& in, bool promt)
|
||||||
{
|
{
|
||||||
size_t number_count;
|
size_t number_count;
|
||||||
cerr << "Enter number_count "; cin >> number_count;
|
if (promt)
|
||||||
|
{
|
||||||
|
cerr << "Enter number count: ";
|
||||||
|
}
|
||||||
|
in >> number_count;
|
||||||
|
|
||||||
vector<double> numbers(number_count);
|
Input it;
|
||||||
Input in;
|
it.numbers.resize(number_count);
|
||||||
in.numbers.resize(number_count);
|
|
||||||
cerr << "Enter numbers ";
|
|
||||||
for (size_t i = 0; i < number_count; i++)
|
for (size_t i = 0; i < number_count; i++)
|
||||||
{
|
{
|
||||||
cin >> in.numbers[i];
|
in >> it.numbers[i];
|
||||||
}
|
}
|
||||||
|
if (promt)
|
||||||
size_t bin_count;
|
{
|
||||||
cerr << "Enter bin_count ";
|
cerr << "Enter bin count: ";
|
||||||
cin >> in.bin_count;
|
}
|
||||||
return in;
|
in>> it.bin_count;
|
||||||
|
return it;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t write_data(void* items, size_t item_size, size_t item_count, void* ctx)
|
||||||
|
{
|
||||||
|
size_t data_size = item_size * item_count;
|
||||||
|
stringstream* buffer = reinterpret_cast<stringstream*>(ctx);
|
||||||
|
buffer->write(reinterpret_cast<const char*>(items), data_size);
|
||||||
|
return data_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Input
|
||||||
|
download(const string& address)
|
||||||
|
{
|
||||||
|
stringstream buffer;
|
||||||
|
CURL *curl = curl_easy_init();
|
||||||
|
if(curl)
|
||||||
|
{
|
||||||
|
CURLcode res;
|
||||||
|
curl_easy_setopt(curl, CURLOPT_URL, address.c_str());
|
||||||
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
|
||||||
|
res = curl_easy_perform(curl);
|
||||||
|
if (res != CURLE_OK)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "curl_easy_perform() failed: %s\n",curl_easy_strerror(res));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
curl_easy_cleanup(curl);
|
||||||
|
|
||||||
|
}
|
||||||
|
return input_data(buffer, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
Input input;
|
||||||
|
if (argc > 1)
|
||||||
|
{
|
||||||
|
input = download(argv[1]);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
auto in = input_data();
|
input = input_data(cin, true);
|
||||||
auto bins = make_histogram(in.numbers, in.bin_count);
|
}
|
||||||
|
|
||||||
|
const auto bins = make_histogram(input.numbers, input.bin_count);
|
||||||
show_histogram_svg(bins);
|
show_histogram_svg(bins);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
Двоичный файл не отображается.
@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||||
|
<CodeBlocks_project_file>
|
||||||
|
<FileVersion major="1" minor="6" />
|
||||||
|
<Project>
|
||||||
|
<Option title="svg" />
|
||||||
|
<Option pch_mode="2" />
|
||||||
|
<Option compiler="gcc" />
|
||||||
|
<Build>
|
||||||
|
<Target title="Debug">
|
||||||
|
<Option output="bin/Debug/svg" 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/svg" 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="svg.cpp" />
|
||||||
|
<Unit filename="svg.h" />
|
||||||
|
<Extensions>
|
||||||
|
<lib_finder disable_auto="1" />
|
||||||
|
</Extensions>
|
||||||
|
</Project>
|
||||||
|
</CodeBlocks_project_file>
|
@ -0,0 +1,73 @@
|
|||||||
|
#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) {
|
||||||
|
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, "black", "#fde910");
|
||||||
|
|
||||||
|
top += BIN_HEIGHT;
|
||||||
|
|
||||||
|
}
|
||||||
|
cout << "<line x1='2' y1='1' x2 = '"<<MAX_WIDTH+TEXT_WIDTH<<"' y2 = '1' stroke='black' stroke-dasharray='10 10' />\n";
|
||||||
|
cout << "<line x1='2' y1='1' x2 = '2' y2 = '"<<top+10<<"' stroke='black' stroke-dasharray='10 10' />\n";
|
||||||
|
cout << "<line x1='2' y1='"<<top+10<<"' x2 = '"<<MAX_WIDTH+TEXT_WIDTH<<"' y2 = '"<<top+10<<"' stroke='black' stroke-dasharray='10 10' />\n";
|
||||||
|
cout << "<line x1='"<<MAX_WIDTH+TEXT_WIDTH<<"' y1='"<<top+10<<"' x2 = '"<<MAX_WIDTH+TEXT_WIDTH<<"' y2 = '1' stroke='black' stroke-dasharray='10 10' />\n";
|
||||||
|
svg_end();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
|||||||
|
# depslib dependency file v1.0
|
||||||
|
1682280278 source:c:\users\79156\desktop\3\svg.cpp
|
||||||
|
<math.h>
|
||||||
|
<iostream>
|
||||||
|
<conio.h>
|
||||||
|
<vector>
|
||||||
|
<string>
|
||||||
|
"svg.h"
|
||||||
|
|
||||||
|
1682253694 c:\users\79156\desktop\3\svg.h
|
||||||
|
<vector>
|
||||||
|
|
||||||
|
1682252851 c:\users\79156\desktop\3\svg.cpp
|
||||||
|
<iostream>
|
||||||
|
<vector>
|
||||||
|
<windows.h>
|
||||||
|
<string>
|
||||||
|
"svg.h"
|
||||||
|
|
@ -0,0 +1,9 @@
|
|||||||
|
#ifndef SVG_H_INCLUDED
|
||||||
|
#define SVG_H_INCLUDED
|
||||||
|
//#include "svg.cpp"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
void
|
||||||
|
show_histogram_svg(const std::vector<size_t>& bins);
|
||||||
|
|
||||||
|
#endif // SVG_H_INCLUDED
|
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||||
|
<CodeBlocks_layout_file>
|
||||||
|
<FileVersion major="1" minor="0" />
|
||||||
|
<ActiveTarget name="Debug" />
|
||||||
|
<File name="svg.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="0" topLine="0" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="svg.cpp" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="0" topLine="0" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
</CodeBlocks_layout_file>
|
@ -0,0 +1,44 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||||
|
<CodeBlocks_project_file>
|
||||||
|
<FileVersion major="1" minor="6" />
|
||||||
|
<Project>
|
||||||
|
<Option title="test" />
|
||||||
|
<Option pch_mode="2" />
|
||||||
|
<Option compiler="gcc" />
|
||||||
|
<Build>
|
||||||
|
<Target title="Debug">
|
||||||
|
<Option output="bin/Debug/test" 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/test" 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="doctest.h" />
|
||||||
|
<Unit filename="histogram.cpp" />
|
||||||
|
<Unit filename="histogram.h" />
|
||||||
|
<Unit filename="histogram_internal.h" />
|
||||||
|
<Unit filename="unittest.cpp" />
|
||||||
|
<Extensions>
|
||||||
|
<lib_finder disable_auto="1" />
|
||||||
|
</Extensions>
|
||||||
|
</Project>
|
||||||
|
</CodeBlocks_project_file>
|
@ -0,0 +1,130 @@
|
|||||||
|
# depslib dependency file v1.0
|
||||||
|
1681135804 source:c:\users\u111-09\desktop\1\histogram.cpp
|
||||||
|
<iostream>
|
||||||
|
<vector>
|
||||||
|
"histogram_internal.h"
|
||||||
|
|
||||||
|
1681131906 c:\users\u111-09\desktop\1\histogram.h
|
||||||
|
<vector>
|
||||||
|
|
||||||
|
1681135819 c:\users\u111-09\desktop\1\histogram_internal.h
|
||||||
|
<vector>
|
||||||
|
|
||||||
|
1681135806 source:d:\3\histogram.cpp
|
||||||
|
<iostream>
|
||||||
|
<vector>
|
||||||
|
"histogram_internal.h"
|
||||||
|
|
||||||
|
1681135820 d:\3\histogram_internal.h
|
||||||
|
<vector>
|
||||||
|
|
||||||
|
1682078902 source:d:\3\unittest.cpp
|
||||||
|
"doctest.h"
|
||||||
|
"histogram_internal.h"
|
||||||
|
|
||||||
|
1681134424 d:\3\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>
|
||||||
|
|
||||||
|
1682333182 source:c:\users\79156\desktop\3\histogram.cpp
|
||||||
|
<iostream>
|
||||||
|
<vector>
|
||||||
|
<windows.h>
|
||||||
|
"histogram.h"
|
||||||
|
|
||||||
|
1682282091 c:\users\79156\desktop\3\histogram_internal.h
|
||||||
|
<vector>
|
||||||
|
|
||||||
|
1682338695 source:c:\users\79156\desktop\3\unittest.cpp
|
||||||
|
"doctest.h"
|
||||||
|
"histogram_internal.h"
|
||||||
|
|
||||||
|
1681134424 c:\users\79156\desktop\3\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>
|
||||||
|
|
||||||
|
1681131908 c:\users\79156\desktop\3\histogram.h
|
||||||
|
<vector>
|
||||||
|
|
@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||||
|
<CodeBlocks_layout_file>
|
||||||
|
<FileVersion major="1" minor="0" />
|
||||||
|
<ActiveTarget name="Debug" />
|
||||||
|
<File name="histogram.cpp" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="149" topLine="33" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="histogram_internal.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="176" topLine="0" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="doctest.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="0" topLine="0" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="unittest.cpp" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="1428" topLine="32" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
</CodeBlocks_layout_file>
|
@ -0,0 +1,23 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
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,9 @@
|
|||||||
|
#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,61 @@
|
|||||||
|
#define DOCTEST_CONFIG_NO_MULTITHREADING
|
||||||
|
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
||||||
|
#include "doctest.h"
|
||||||
|
#include "histogram_internal.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TEST_CASE("null vector") {
|
||||||
|
double min = 0;
|
||||||
|
double max = 0;
|
||||||
|
find_minmax({}, min, max);
|
||||||
|
CHECK(find_minmax({}, min, max) == true);
|
||||||
|
CHECK(min == 1);
|
||||||
|
CHECK(max == 2);
|
||||||
|
|
||||||
|
CHECK(find_minmax({}, min, max) == false);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("one number") {
|
||||||
|
double min = 0;
|
||||||
|
double max = 0;
|
||||||
|
find_minmax({1}, min, max);
|
||||||
|
CHECK(find_minmax({1}, min, max) == true);
|
||||||
|
CHECK(min == 1);
|
||||||
|
CHECK(max == 2);
|
||||||
|
|
||||||
|
CHECK(find_minmax({}, min, max) == false);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("negative numbers") {
|
||||||
|
double min = 0;
|
||||||
|
double max = 0;
|
||||||
|
find_minmax({-1, -2}, min, max);
|
||||||
|
CHECK(find_minmax({-1, -2}, min, max) == true);
|
||||||
|
CHECK(min == 1);
|
||||||
|
CHECK(max == 2);
|
||||||
|
|
||||||
|
CHECK(find_minmax({}, min, max) == false);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("same numbers") {
|
||||||
|
double min = 0;
|
||||||
|
double max = 0;
|
||||||
|
find_minmax({1, 1}, min, max);
|
||||||
|
CHECK(find_minmax({1, 1}, min, max) == true);
|
||||||
|
CHECK(min == 1);
|
||||||
|
CHECK(max == 2);
|
||||||
|
|
||||||
|
CHECK(find_minmax({}, min, max) == false);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("distinct positive numbers") {
|
||||||
|
double min = 0;
|
||||||
|
double max = 0;
|
||||||
|
find_minmax({1, 2}, min, max);
|
||||||
|
CHECK(find_minmax({1, 2}, min, max) == true);
|
||||||
|
CHECK(min == 1);
|
||||||
|
CHECK(max == 2);
|
||||||
|
|
||||||
|
CHECK(find_minmax({}, min, max) == false);
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
# depslib dependency file v1.0
|
||||||
|
1681133536 source:c:\users\u111-09\desktop\1\histogram.cpp
|
||||||
|
<iostream>
|
||||||
|
<vector>
|
||||||
|
"histogram.h"
|
||||||
|
|
||||||
|
1681131906 c:\users\u111-09\desktop\1\histogram.h
|
||||||
|
<vector>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче