diff --git a/bin/Debug/devlab1.exe b/bin/Debug/devlab1.exe index bdc69c1..eb53047 100644 Binary files a/bin/Debug/devlab1.exe and b/bin/Debug/devlab1.exe differ diff --git a/devlab1.depend b/devlab1.depend index 826bae6..a2d396f 100644 --- a/devlab1.depend +++ b/devlab1.depend @@ -1,5 +1,5 @@ # depslib dependency file v1.0 -1682334548 source:c:\program files\codeblocks\devlab1\main.cpp +1685054501 source:c:\program files\codeblocks\devlab1\main.cpp @@ -24,7 +24,7 @@ 1682337558 c:\program files\codeblocks\devlab1\svg.h -1682339123 source:c:\program files\codeblocks\devlab1\svg.cpp +1685054342 source:c:\program files\codeblocks\devlab1\svg.cpp "svg.h" diff --git a/histogram.cpp b/histogram.cpp index f587c5b..054221b 100644 --- a/histogram.cpp +++ b/histogram.cpp @@ -23,8 +23,8 @@ make_histogram(const vector &numbers,size_t bin_count) { float lo,hi,dif; double min, max; - if(!find_minmax(numbers, min, max)) - return 1; + // if(!find_minmax(numbers, min, max)) + // return 1; vector bins(bin_count) ; dif=(max - min)/bin_count; for(int i=0; i < numbers.size(); i++) diff --git a/main.cpp b/main.cpp index 5d48798..7d0ed20 100644 --- a/main.cpp +++ b/main.cpp @@ -12,22 +12,31 @@ struct Input int bin_count; }; Input -input_data() +input_data(istream& in) { size_t number_count=0; - cerr<<"amount of numbers is "; - cin >> number_count; - Input in; - in.numbers.resize(number_count); - cerr<<"let's intro numbers "; + bool prompt; + if (promt){ + cerr<<"amount of numbers is "; + } + + in >> number_count; + Input inp; + inp.numbers.resize(number_count); + if (promt){ + cerr<<"let's intro numbers "; + } + for (size_t i = 0; i < number_count; i++) { - cin >> in.numbers[i]; + in >> inp.numbers[i]; } size_t bin_count=0; + if (promt){ cerr<<"amount of bins is "; - cin >> in.bin_count; - return in; + } + in >> inp.bin_count; + return inp; } //4199705 //0x71fdf8 @@ -35,14 +44,14 @@ input_data() int main() { - auto in = input_data(); + auto inp = input_data(cin); //std::cout<30) - { - cerr<< "too big, please make it smaller\n"; - return false; - } - if (BLOCK_WIDTH<3) - { - cerr<< "too small, please make it bigger\n"; - return false; - } - return true; -} void svg_begin(double width, double height) @@ -56,7 +42,7 @@ show_histogram_svg(vector & bins) const auto IMAGE_HEIGHT = 300; const auto TEXT_LEFT = 20; const auto TEXT_BASELINE = 20; - + const auto BLOCK_WIDTH = 20; const auto TEXT_WIDTH = 50; const auto BIN_HEIGHT = 30; const auto MAX_ASTERISK1 = 30; @@ -73,14 +59,7 @@ show_histogram_svg(vector & bins) int i = 0; - int BLOCK_WIDTH; - while (true){ - cerr << "block width: "; - cin >> BLOCK_WIDTH; - if(inbl(BLOCK_WIDTH)) - break; - } auto maxb1 = maxb * BLOCK_WIDTH;