защита лабораторной работы

main
ShchegolikhYR 1 месяц назад
Родитель 8ddec8f599
Сommit 6184143fe3

Двоичные данные
.DS_Store поставляемый

Двоичный файл не отображается.

@ -11,6 +11,7 @@
52D010C52DC397980091060B /* histogram.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52D010C42DC397980091060B /* histogram.cpp */; };
52D010C62DC39F250091060B /* histogram.hpp in Sources */ = {isa = PBXBuildFile; fileRef = 52D010C32DC397980091060B /* histogram.hpp */; };
52FD91E52DC3AA580037B82C /* text.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52FD91E42DC3AA580037B82C /* text.cpp */; };
52FD92082DC3CAAB0037B82C /* svg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52FD92072DC3CAAB0037B82C /* svg.cpp */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
@ -32,6 +33,10 @@
52E197562D5F35A1004F8E3E /* Gistogramma */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Gistogramma; sourceTree = BUILT_PRODUCTS_DIR; };
52FD91E32DC3AA580037B82C /* text.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = text.hpp; sourceTree = "<group>"; };
52FD91E42DC3AA580037B82C /* text.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = text.cpp; sourceTree = "<group>"; };
52FD91F72DC3BE4E0037B82C /* .gitignore */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitignore; sourceTree = "<group>"; };
52FD91FA2DC3C02E0037B82C /* histogram_internal.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = histogram_internal.hpp; sourceTree = "<group>"; };
52FD92062DC3CAAB0037B82C /* svg.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = svg.hpp; sourceTree = "<group>"; };
52FD92072DC3CAAB0037B82C /* svg.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = svg.cpp; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -48,11 +53,15 @@
52E1974D2D5F35A1004F8E3E = {
isa = PBXGroup;
children = (
52FD91FA2DC3C02E0037B82C /* histogram_internal.hpp */,
52FD91E32DC3AA580037B82C /* text.hpp */,
52FD91E42DC3AA580037B82C /* text.cpp */,
52D010C32DC397980091060B /* histogram.hpp */,
52D010C42DC397980091060B /* histogram.cpp */,
52FD92062DC3CAAB0037B82C /* svg.hpp */,
52FD92072DC3CAAB0037B82C /* svg.cpp */,
523FBF7D2DA909BA0044A741 /* main.cpp */,
52FD91F72DC3BE4E0037B82C /* .gitignore */,
52E197572D5F35A1004F8E3E /* Products */,
);
sourceTree = "<group>";
@ -126,6 +135,7 @@
buildActionMask = 2147483647;
files = (
523FBF7E2DA909BA0044A741 /* main.cpp in Sources */,
52FD92082DC3CAAB0037B82C /* svg.cpp in Sources */,
52D010C52DC397980091060B /* histogram.cpp in Sources */,
52FD91E52DC3AA580037B82C /* text.cpp in Sources */,
52D010C62DC39F250091060B /* histogram.hpp in Sources */,

Двоичный файл не отображается.

@ -110,11 +110,123 @@
filePath = "main.cpp"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "86"
endingLineNumber = "86"
startingLineNumber = "34"
endingLineNumber = "34"
landmarkName = "main()"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "6ECD73DE-9D0C-4559-A10E-25AB7E57E885"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "svg.cpp"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "32"
endingLineNumber = "32"
landmarkName = "show_histogram_svg(bins)"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "FD956AA5-AD51-4B78-B2BB-8C8FE466AD72"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "svg.cpp"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "38"
endingLineNumber = "38"
landmarkName = "show_histogram_svg(bins)"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "8E3E1B3E-B738-488A-881B-2B5B5E4AC633"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "svg.cpp"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "43"
endingLineNumber = "43"
landmarkName = "show_histogram_svg(bins)"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "107D9ED3-A4F0-4505-B67D-97969128F209"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "svg.cpp"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "54"
endingLineNumber = "54"
landmarkName = "show_histogram_svg(bins)"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "C8505EF0-D299-4216-9261-0ABE6E310528"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "svg.cpp"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "48"
endingLineNumber = "48"
landmarkName = "show_histogram_svg(bins)"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "34377FD2-9448-4E1A-8E31-18AAF0D22208"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "svg.cpp"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "47"
endingLineNumber = "47"
landmarkName = "show_histogram_svg(bins)"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "1DE36046-C7B1-4D6C-9C2F-225BFA9AC5AA"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "svg.cpp"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "36"
endingLineNumber = "36"
landmarkName = "show_histogram_svg(bins)"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>

@ -10,5 +10,13 @@
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>52E197552D5F35A1004F8E3E</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>

@ -3,14 +3,15 @@
using namespace std;
void find_minmax(const vector<double>& numbers, double& minimum, double& maximum){
if (numbers.size() == 0) return;
bool find_minmax(const vector<double>& numbers, double& minimum, double& maximum){
if (numbers.size() == 0) return 1;
minimum = numbers[0];
maximum = numbers[0];
for (auto i : numbers) {
if (i < minimum) minimum = i;
if (i > maximum) maximum = i;
}
return 0;
}
vector<size_t> make_histogram(const vector<double>& numbers, size_t& bin_count) {

@ -2,6 +2,6 @@
#define histogram_internal_h
#include <vector>
void find_minmax(const std::vector<double>& numbers, double& minimum, double& maximum);
bool find_minmax(const std::vector<double>& numbers, double& minimum, double& maximum);
#endif /* histogram_internal_h */

@ -29,8 +29,11 @@ void show_histogram_svg(const vector<size_t>& bins) {
const auto TEXT_WIDTH = 50;
const auto BIN_HEIGHT = 30;
const auto BLOCK_WIDTH = 10;
const auto MAX_BIN_WIDTH = IMAGE_WIDTH - TEXT_WIDTH;
const auto MAX_BIN_WIDTH = IMAGE_WIDTH - 2.3 * TEXT_WIDTH;
auto max_bins = bins[0];
size_t sum_bins = 0;
for (size_t bin : bins) sum_bins += bin;
for (size_t bin : bins) {
if (bin > max_bins) max_bins = bin;
@ -42,8 +45,10 @@ void show_histogram_svg(const vector<size_t>& bins) {
double top = 0;
for (size_t bin : bins) {
const double bin_width = BLOCK_WIDTH * bin * koef;
size_t percent = bin * 100 / sum_bins;
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin));
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT);
svg_text((IMAGE_WIDTH - TEXT_WIDTH), top + TEXT_BASELINE, to_string(percent));
top += BIN_HEIGHT;
}
svg_end();

@ -7,7 +7,7 @@ using namespace std;
void show_histogram_text(const vector<size_t>& baskets) {
const size_t screen_width = 80;
const size_t max_asterisk = screen_width - 3 - 1;
cout.precision(4);
cout.precision(0);
size_t baskets_max_count;
baskets_max_count = baskets[0];

@ -14,11 +14,10 @@ TEST_CASE("distinct positive numbers") {
}
TEST_CASE("empty vector"){
double min = NULL;
double max = NULL;
find_minmax({}, min, max);
CHECK(min == NULL);
CHECK(max == NULL);
double min = 0;
double max = 0;
bool check = find_minmax({}, min, max);
CHECK(check == 1);
}
TEST_CASE("single vector"){

Загрузка…
Отмена
Сохранить