diff --git a/bin/Debug/devlab1.exe b/bin/Debug/devlab1.exe index e209b2a..d1b77f8 100644 Binary files a/bin/Debug/devlab1.exe and b/bin/Debug/devlab1.exe differ diff --git a/devlab1.cbp b/devlab1.cbp index f398066..54beaa3 100644 --- a/devlab1.cbp +++ b/devlab1.cbp @@ -35,7 +35,12 @@ + + + + + diff --git a/devlab1.depend b/devlab1.depend index 2186c4e..3936491 100644 --- a/devlab1.depend +++ b/devlab1.depend @@ -1,5 +1,18 @@ # depslib dependency file v1.0 -1676897437 source:c:\program files\codeblocks\devlab1\main.cpp +1680528158 source:c:\program files\codeblocks\devlab1\main.cpp + "histogram.h" + "text.h" + +1680530141 c:\program files\codeblocks\devlab1\histogram.h + + +1680530029 source:c:\program files\codeblocks\devlab1\histogram.cpp + "histogram.h" + + +1680530385 c:\program files\codeblocks\devlab1\text.h + + diff --git a/devlab1.layout b/devlab1.layout index 314cf27..cecc2f7 100644 --- a/devlab1.layout +++ b/devlab1.layout @@ -2,9 +2,29 @@ - + - + + + + + + + + + + + + + + + + + + + + + diff --git a/histogram.cpp b/histogram.cpp new file mode 100644 index 0000000..bd4803e --- /dev/null +++ b/histogram.cpp @@ -0,0 +1,43 @@ +#include "histogram.h" +#include +using namespace std; +void +find_minmax(const vector& numbers, double& min, double& max) +{ + min = numbers[0]; + max = numbers[0]; + for ( size_t i=0; i < numbers.size(); i++) + { + if (numbers[i] > max) max=numbers[i]; + if (numbers[i] < min) min=numbers[i]; + } +}; + +std::vector +make_histogram(const vector& numbers,size_t bin_count) +{ + float lo,hi,dif; + double min, max; + find_minmax(numbers, min, max); + vector bins(bin_count) ; + dif=(max - min)/bin_count; + for(int i=0; i < numbers.size(); i++) + { + bool found = false; + for (int j=0; (j < bin_count-1)&&!found; j++) + { + lo= min + j*dif; + hi= min + (j+1)*dif; + if ((lo <= numbers[i]) && (numbers[i] + +std::vector +make_histogram(const std::vector& numbers, size_t bin_count); + + + +#endif // HISTOGRAM_H_INCLUDED diff --git a/histogram_internal.h b/histogram_internal.h new file mode 100644 index 0000000..a31e616 --- /dev/null +++ b/histogram_internal.h @@ -0,0 +1,6 @@ +#ifndef HISTOGRAM_INTERNAL_H_INCLUDED +#define HISTOGRAM_INTERNAL_H_INCLUDED + +find_minmax(const std::vector& numbers, double& min, double& max) + +#endif // HISTOGRAM_INTERNAL_H_INCLUDED diff --git a/main.cpp b/main.cpp index 9ef49d5..b27901f 100644 --- a/main.cpp +++ b/main.cpp @@ -1,5 +1,8 @@ #include #include +#include "histogram.h" +#include "text.h" + using namespace std; struct Input @@ -23,61 +26,7 @@ input_data() return in; } -void -find_minmax(const vector& numbers, double& min, double& max) -{ - min = numbers[0]; - max = numbers[0]; - for ( size_t i=0; i < numbers.size(); i++) - { - if (numbers[i] > max) max=numbers[i]; - if (numbers[i] < min) min=numbers[i]; - } -}; -std::vector -make_histogram(const vector& numbers,size_t bin_count) -{ - float lo,hi,dif; - double min, max; - find_minmax(numbers, min, max); - vector bins(bin_count) ; - dif=(max - min)/bin_count; - for(int i=0; i < numbers.size(); i++) - { - bool found = false; - for (int j=0; (j < bin_count-1)&&!found; j++) - { - lo= min + j*dif; - hi= min + (j+1)*dif; - if ((lo <= numbers[i]) && (numbers[i] &bins) -{ - for (size_t i=0; i &bins) +{ + for (size_t i=0; i &bins) +{ + for (size_t i=0; i +#include + +void show_histogram_text(std::vector &bins); + + +#endif // TEXT_H_INCLUDED diff --git a/unittest.cbp b/unittest.cbp new file mode 100644 index 0000000..6da4486 --- /dev/null +++ b/unittest.cbp @@ -0,0 +1,36 @@ + + + + + + diff --git a/unittest.layout b/unittest.layout new file mode 100644 index 0000000..593c06e --- /dev/null +++ b/unittest.layout @@ -0,0 +1,5 @@ + + + + +