Сравнить коммиты
Ничего общего в коммитах. '89f5920b565bc19c128d2f66c7631335227c3e39' и '3f2a04f00d866f4911bdec4953969ff6efd7b567' имеют совершенно разные истории.
89f5920b56
...
3f2a04f00d
@ -1,4 +0,0 @@
|
|||||||
/bin
|
|
||||||
/obj
|
|
||||||
/1.layout
|
|
||||||
/curl
|
|
@ -1,104 +0,0 @@
|
|||||||
# 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
|
|
||||||
|
|
@ -1,62 +0,0 @@
|
|||||||
#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;
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
#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
|
|
||||||
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
|||||||
#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,89 +1,51 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <conio.h>
|
#include <cmath>
|
||||||
|
#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(istream& in, bool promt)
|
input_data()
|
||||||
{
|
{
|
||||||
size_t number_count;
|
size_t number_count;
|
||||||
if (promt)
|
cerr << "Enter number_count "; cin >> number_count;
|
||||||
{
|
|
||||||
cerr << "Enter number count: ";
|
|
||||||
}
|
|
||||||
in >> number_count;
|
|
||||||
|
|
||||||
Input it;
|
|
||||||
it.numbers.resize(number_count);
|
vector<double> numbers(number_count);
|
||||||
|
Input in;
|
||||||
|
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++)
|
||||||
{
|
{
|
||||||
in >> it.numbers[i];
|
cin >> in.numbers[i];
|
||||||
}
|
|
||||||
if (promt)
|
|
||||||
{
|
|
||||||
cerr << "Enter bin count: ";
|
|
||||||
}
|
}
|
||||||
in>> it.bin_count;
|
|
||||||
return it;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t write_data(void* items, size_t item_size, size_t item_count, void* ctx)
|
size_t bin_count;
|
||||||
{
|
cerr << "Enter bin_count ";
|
||||||
size_t data_size = item_size * item_count;
|
cin >> in.bin_count;
|
||||||
stringstream* buffer = reinterpret_cast<stringstream*>(ctx);
|
return in;
|
||||||
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 argc, char* argv[])
|
|
||||||
{
|
|
||||||
Input input;
|
|
||||||
if (argc > 1)
|
|
||||||
{
|
|
||||||
input = download(argv[1]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
input = input_data(cin, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto bins = make_histogram(input.numbers, input.bin_count);
|
int main()
|
||||||
|
{
|
||||||
|
auto in = input_data();
|
||||||
|
auto bins = make_histogram(in.numbers, in.bin_count);
|
||||||
show_histogram_svg(bins);
|
show_histogram_svg(bins);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
Двоичный файл не отображается.
@ -1,40 +0,0 @@
|
|||||||
<?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>
|
|
@ -1,73 +0,0 @@
|
|||||||
#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();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
|||||||
# 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"
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
|||||||
#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
|
|
@ -1,15 +0,0 @@
|
|||||||
<?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>
|
|
@ -1,44 +0,0 @@
|
|||||||
<?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>
|
|
@ -1,130 +0,0 @@
|
|||||||
# 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>
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
|||||||
<?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>
|
|
@ -1,23 +0,0 @@
|
|||||||
#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";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
|||||||
#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
|
|
@ -1,61 +0,0 @@
|
|||||||
#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);
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
# 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>
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче