code: защита
Этот коммит содержится в:
13
JIa6a_3.cbp
13
JIa6a_3.cbp
@@ -32,7 +32,20 @@
|
|||||||
<Add option="-Wall" />
|
<Add option="-Wall" />
|
||||||
<Add option="-fexceptions" />
|
<Add option="-fexceptions" />
|
||||||
</Compiler>
|
</Compiler>
|
||||||
|
<Unit filename="histogram.cpp" />
|
||||||
|
<Unit filename="histogram.h">
|
||||||
|
<Option target="<{~None~}>" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="histogram_internal.h">
|
||||||
|
<Option target="<{~None~}>" />
|
||||||
|
</Unit>
|
||||||
<Unit filename="main.cpp" />
|
<Unit filename="main.cpp" />
|
||||||
|
<Unit filename="svg.cpp" />
|
||||||
|
<Unit filename="svg.h" />
|
||||||
|
<Unit filename="text.cpp" />
|
||||||
|
<Unit filename="text.h">
|
||||||
|
<Option target="<{~None~}>" />
|
||||||
|
</Unit>
|
||||||
<Extensions />
|
<Extensions />
|
||||||
</Project>
|
</Project>
|
||||||
</CodeBlocks_project_file>
|
</CodeBlocks_project_file>
|
||||||
|
|||||||
36
JIa6a_3.depend
Обычный файл
36
JIa6a_3.depend
Обычный файл
@@ -0,0 +1,36 @@
|
|||||||
|
# depslib dependency file v1.0
|
||||||
|
1746405872 source:c:\kog cpp\jia6bl no npore\2 cemectp\jia6a_3\jia6a_3_project\histogram.cpp
|
||||||
|
"histogram.h"
|
||||||
|
<vector>
|
||||||
|
|
||||||
|
1746351454 c:\kog cpp\jia6bl no npore\2 cemectp\jia6a_3\jia6a_3_project\histogram.h
|
||||||
|
<vector>
|
||||||
|
|
||||||
|
1747656559 source:c:\kog cpp\jia6bl no npore\2 cemectp\jia6a_3\jia6a_3_project\main.cpp
|
||||||
|
<cstdio>
|
||||||
|
<cstdlib>
|
||||||
|
<iostream>
|
||||||
|
<vector>
|
||||||
|
<cmath>
|
||||||
|
"histogram.h"
|
||||||
|
"text.h"
|
||||||
|
"svg.h"
|
||||||
|
|
||||||
|
1746352309 c:\kog cpp\jia6bl no npore\2 cemectp\jia6a_3\jia6a_3_project\text.h
|
||||||
|
<vector>
|
||||||
|
|
||||||
|
1747656828 c:\kog cpp\jia6bl no npore\2 cemectp\jia6a_3\jia6a_3_project\svg.h
|
||||||
|
<vector>
|
||||||
|
<string>
|
||||||
|
|
||||||
|
1747656828 source:c:\kog cpp\jia6bl no npore\2 cemectp\jia6a_3\jia6a_3_project\svg.cpp
|
||||||
|
<iostream>
|
||||||
|
"svg.h"
|
||||||
|
<vector>
|
||||||
|
<string>
|
||||||
|
|
||||||
|
1746352405 source:c:\kog cpp\jia6bl no npore\2 cemectp\jia6a_3\jia6a_3_project\text.cpp
|
||||||
|
"text.h"
|
||||||
|
<vector>
|
||||||
|
<iostream>
|
||||||
|
|
||||||
14
main.cpp
14
main.cpp
@@ -36,15 +36,27 @@ Input input_data(){
|
|||||||
return stct;
|
return stct;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Ââîä ïàðàìåòðîâ ÷åðòî÷êè
|
||||||
|
void dash_param(size_t& length_dsh, size_t& length_invl){
|
||||||
|
cerr << "Enter length dash ";
|
||||||
|
cin >> length_dsh;
|
||||||
|
cerr << "Enter length interval ";
|
||||||
|
cin >> length_invl;
|
||||||
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
//Ââîä ìàññèâà è êîëè÷åñòâà êîðçèí
|
//Ââîä ìàññèâà è êîëè÷åñòâà êîðçèí
|
||||||
Input in = input_data();
|
Input in = input_data();
|
||||||
|
|
||||||
|
//Ââîä äëèíû ÷åðòû è èíòåðâàëà ìåæäó ÷åðòàìè
|
||||||
|
size_t length_dash, length_interval;
|
||||||
|
dash_param(length_dash, length_interval);
|
||||||
|
|
||||||
//Ñîçäàíèå âåêòîðà bins äëÿ ãèñòîãðàììû
|
//Ñîçäàíèå âåêòîðà bins äëÿ ãèñòîãðàììû
|
||||||
vector<size_t> bins = make_histogram(in.Numbers, in.bin_count);
|
vector<size_t> bins = make_histogram(in.Numbers, in.bin_count);
|
||||||
|
|
||||||
//Âûâîä ãèñòîãðàììû
|
//Âûâîä ãèñòîãðàììû
|
||||||
show_histogram_svg(bins);
|
show_histogram_svg(bins, length_dash, length_interval);
|
||||||
//show_histogram_text(bins);
|
//show_histogram_text(bins);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
14
svg.cpp
14
svg.cpp
@@ -23,7 +23,7 @@ void svg_text(double left, double baseline, std::string text)
|
|||||||
std::cout << "<text x='" << left << "' y='" << baseline << "'>" << text << "</text>";
|
std::cout << "<text x='" << left << "' y='" << baseline << "'>" << text << "</text>";
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_histogram_svg(const std::vector<size_t>& bins)
|
void show_histogram_svg(const std::vector<size_t>& bins, const size_t length_dsh, const size_t length_invl)
|
||||||
{
|
{
|
||||||
const auto IMAGE_WIDTH = 400;
|
const auto IMAGE_WIDTH = 400;
|
||||||
const auto IMAGE_HEIGHT = 300;
|
const auto IMAGE_HEIGHT = 300;
|
||||||
@@ -43,6 +43,8 @@ void show_histogram_svg(const std::vector<size_t>& bins)
|
|||||||
if (bin > max_bin) max_bin = bin;
|
if (bin > max_bin) max_bin = bin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string dash_pattern = std::to_string(length_dsh) + " " + std::to_string(length_invl);
|
||||||
|
|
||||||
if (max_bin * BLOCK_WIDTH > MAX_AVAIL_WIDTH)
|
if (max_bin * BLOCK_WIDTH > MAX_AVAIL_WIDTH)
|
||||||
{
|
{
|
||||||
// ìàñøòàáíûé êîýôôèöèåíò
|
// ìàñøòàáíûé êîýôôèöèåíò
|
||||||
@@ -55,6 +57,7 @@ void show_histogram_svg(const std::vector<size_t>& bins)
|
|||||||
|
|
||||||
svg_text(TEXT_LEFT, top + TEXT_BASELINE, std::to_string(bin));
|
svg_text(TEXT_LEFT, top + TEXT_BASELINE, std::to_string(bin));
|
||||||
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT);
|
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT);
|
||||||
|
svg_line(0, top + BIN_HEIGHT, IMAGE_WIDTH, top + BIN_HEIGHT, dash_pattern);
|
||||||
top += BIN_HEIGHT;
|
top += BIN_HEIGHT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -66,6 +69,7 @@ void show_histogram_svg(const std::vector<size_t>& bins)
|
|||||||
const double bin_width = BLOCK_WIDTH * bin;
|
const double bin_width = BLOCK_WIDTH * bin;
|
||||||
svg_text(TEXT_LEFT, top + TEXT_BASELINE, std::to_string(bin));
|
svg_text(TEXT_LEFT, top + TEXT_BASELINE, std::to_string(bin));
|
||||||
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT);
|
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT);
|
||||||
|
svg_line(0, top + BIN_HEIGHT, IMAGE_WIDTH, top + BIN_HEIGHT, dash_pattern);
|
||||||
top += BIN_HEIGHT;
|
top += BIN_HEIGHT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,3 +81,11 @@ void svg_rect(double x, double y, double width, double height, std::string strok
|
|||||||
{
|
{
|
||||||
std::cout << "<rect x='" << x << "' y='" << y << "' width='" << width << "' height='" << height << "' stroke='" << stroke << "' fill='" << fill << "' />";
|
std::cout << "<rect x='" << x << "' y='" << y << "' width='" << width << "' height='" << height << "' stroke='" << stroke << "' fill='" << fill << "' />";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//çàùèòà
|
||||||
|
void svg_line(double x1, double y1, double x2, double y2, const std::string stroke_dasharray){
|
||||||
|
std::cout << "<line x1='" << x1 << "' y1='" << y1 << "' x2='" << x2 << "' y2='" << y2
|
||||||
|
<< "' stroke='black' stroke-dasharray='" << stroke_dasharray << "' />\n";
|
||||||
|
}
|
||||||
|
|||||||
5
svg.h
5
svg.h
@@ -5,8 +5,11 @@
|
|||||||
|
|
||||||
void svg_begin(double width, double height);
|
void svg_begin(double width, double height);
|
||||||
void svg_end();
|
void svg_end();
|
||||||
void show_histogram_svg(const std::vector<size_t>& bins);
|
void show_histogram_svg(const std::vector<size_t>& bins, const size_t length_dsh, const size_t length_invl);
|
||||||
void svg_text(double left, double baseline, std::string text);
|
void svg_text(double left, double baseline, std::string text);
|
||||||
void svg_rect(double x, double y, double width, double height, std::string stroke = "black", std::string fill = "black");
|
void svg_rect(double x, double y, double width, double height, std::string stroke = "black", std::string fill = "black");
|
||||||
|
|
||||||
|
//çàùèòà
|
||||||
|
void svg_line(double x1, double y1, double x2, double y2, const std::string stroke_dasharray);
|
||||||
|
|
||||||
#endif // SVG_H_INCLUDED
|
#endif // SVG_H_INCLUDED
|
||||||
|
|||||||
@@ -31,6 +31,10 @@
|
|||||||
<Compiler>
|
<Compiler>
|
||||||
<Add option="-Wall" />
|
<Add option="-Wall" />
|
||||||
</Compiler>
|
</Compiler>
|
||||||
|
<Unit filename="doctest.h" />
|
||||||
|
<Unit filename="histogram.cpp" />
|
||||||
|
<Unit filename="histogram_internal.h" />
|
||||||
|
<Unit filename="unittest.cpp" />
|
||||||
<Extensions />
|
<Extensions />
|
||||||
</Project>
|
</Project>
|
||||||
</CodeBlocks_project_file>
|
</CodeBlocks_project_file>
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user