Сравнить коммиты

..

Ничего общего в коммитах. '9e6c5d3142c0d20a1ae7cd6734c64676182485dc' и '80edb8c280723d2d24f6322b2800b23f5979ed1d' имеют совершенно разные истории.

@ -20,12 +20,12 @@ void find_minmax(const std::vector <double> &numbers, double &min, double &max,
}
}
std::vector <std::size_t> make_histogram( const std::vector<double> &numbers, std::size_t bin_count) {
std::vector <int> make_histogram( std::vector<double> &numbers, size_t &bin_count) {
double min, max;
bool res = false;
find_minmax(numbers, min, max, res);
double bin_size = ( max - min ) / bin_count;
std::vector<std::size_t> bins ( bin_count );
std::vector<int> bins ( bin_count );
for (std::size_t i=0; i < numbers.size(); i++ ){
bool found = false;
for (std::size_t j = 0; ( j < bin_count - 1 ) && !found; j++ ){
@ -42,4 +42,3 @@ std::vector <std::size_t> make_histogram( const std::vector<double> &numbers, st
}
return bins;
}

@ -3,6 +3,7 @@
#include <vector>
std::vector <std::size_t> make_histogram(const std::vector<double> &numbers, std::size_t bin_count);
std::vector<int>
make_histogram(const std::vector<double> &numbers, std::size_t &bin_count);
#endif // HISTOGRAM_H_INCLUDED

@ -17,7 +17,6 @@
<Linker>
<Add option="-static-libstdc++" />
<Add option="-static-libgcc" />
<Add option="-static" />
</Linker>
</Target>
<Target title="Release">
@ -37,10 +36,6 @@
<Add option="-Wall" />
<Add option="-fexceptions" />
</Compiler>
<Unit filename="aver.cpp" />
<Unit filename="aver.h">
<Option target="&lt;{~None~}&gt;" />
</Unit>
<Unit filename="doctest.h" />
<Unit filename="histogram.cpp" />
<Unit filename="histogram.h" />

@ -3,7 +3,6 @@
#include "histogram.h"
#include "text.h"
#include "svg.h"
#include "aver.h"
using namespace std;
@ -41,6 +40,8 @@ Input input_data() {
int main(){
bool res = false;
Input in = input_data();
auto bins = make_histogram(in.numbers, in.bin_count);

@ -1,9 +1,6 @@
#include <iostream>
#include <vector>
#include "svg.h"
#include "aver.h"
void
svg_begin(double width, double height) {
@ -25,17 +22,12 @@ svg_text(double left, double baseline, std::string text) {
std::cout << "<text x='" << left << "' y='"<< baseline << "' > " << text << " </text>";
}
void svg_rect(double x, double y, double width, double height,int res){
if(res == 1){
std::cout << "<rect x='" << x << "' y='" << y << "' width='" << width << "' height='" << height << " ' stroke='green' fill='#008000' ></rect>";
}if(res==2){
std::cout << "<rect x='" << x << "' y='" << y << "' width='" << width << "' height='" << height << " ' stroke='red' fill='#FF0000 ' ></rect>";
}
void svg_rect(double x, double y, double width, double height){
std::cout << "<rect x='" << x << "' y='" << y << "' width='" << width << "' height='" << height << " ' stroke='black' fill='#33A220' ></rect>";
}
void
show_histogram_svg(const std::vector <std::size_t> &bins) {
show_histogram_svg(const std::vector <int> bins) {
const auto IMAGE_WIDTH = 400;
const auto IMAGE_HEIGHT = 300;
@ -55,12 +47,11 @@ show_histogram_svg(const std::vector <std::size_t> &bins) {
}
}
if (maxbin<=76){
for (std::size_t i=0; i < bins.size(); i++) {
double bin_width = BLOCK_WIDTH * bins[i];
svg_text(TEXT_LEFT, top + TEXT_BASELINE, std::to_string(bins[i]));
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT,compareHeightToAverage(bins,i));
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT);
top += BIN_HEIGHT;
}
svg_end();
@ -68,7 +59,7 @@ show_histogram_svg(const std::vector <std::size_t> &bins) {
for (std::size_t i=0; i < bins.size(); i++) {
double bin_width= MAX_ASTERISK * (static_cast<double>(bins[i]) / maxbin);
svg_text(TEXT_LEFT, top + TEXT_BASELINE, std::to_string(bins[i]));
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT,compareHeightToAverage(bins,i));
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT);
top += BIN_HEIGHT;
}
svg_end();

@ -3,6 +3,7 @@
#include <vector>
void show_histogram_svg(const std::vector<std::size_t> &bins);
void
show_histogram_svg(const std::vector<int> &bins);
#endif // SVG_H_INCLUDED

@ -31,12 +31,9 @@
<Compiler>
<Add option="-Wall" />
</Compiler>
<Unit filename="aver.cpp" />
<Unit filename="aver.h" />
<Unit filename="histogram.cpp" />
<Unit filename="histogram.h" />
<Unit filename="histogram_internal.h" />
<Unit filename="test my var.cpp" />
<Unit filename="unittest.cpp" />
<Extensions />
</Project>

@ -3,7 +3,6 @@
#include "doctest.h"
#include <vector>
#include "histogram_internal.h"
#include "aver.h"
TEST_CASE("distinct positive numbers") {
double min = 0;
@ -48,16 +47,3 @@ TEST_CASE("empty array") {
CHECK(min == 0);
CHECK(max == 0);
}
TEST_CASE("my var 1") {
int a=compareHeightToAverage({1,1,2},1);
CHECK(a == 1);
}
TEST_CASE("my var 2") {
int a=compareHeightToAverage({1,1,2},2);
CHECK(a == 2);
}
TEST_CASE("my var 3") {
int a=compareHeightToAverage({2,1,1},3);
CHECK(a == 2);
}

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