main
KhatyukhinYS 11 месяцев назад
Родитель e89c8cef00
Сommit ba2eac6cbc

@ -6,26 +6,29 @@
#include "procent.h"
using namespace std;
struct Input {
std::vector<double> numbers;
vector<double> numbers;
size_t number_count{};
size_t bin_count{};
size_t max_count{};
};
Input
input_data() {
size_t number_count;
input_data(istream& inn) {
Input in;
cin >> number_count;
in.numbers.resize(number_count);
for (size_t i = 0; i < number_count; i++) {
cin >> in.numbers[i];
inn >> in.number_count;
vector<double> numbers(in.number_count);
in.numbers.resize(in.number_count);
for (size_t i = 0; i < in.number_count; i++) {
inn >> in.numbers[i];
}
size_t bin_count;
cin >> in.bin_count;
inn >> in.bin_count;
size_t max_count;
in.max_count = 0;
return in;
}
int main()
{
auto in = input_data();
auto in = input_data(cin);
auto bins = make_histogram(in.numbers, in.bin_count);
auto max_count=bins[0];

@ -19,11 +19,6 @@ svg_text(double left, double baseline, std::string text) {
std::cout << "<text x='"<< left <<"' y='"<< baseline <<"'>"<< text <<"</text>";
}
void
svg_proc(double left, double baseline) {
std::cout << "<text x='"<< left <<"' y='"<< baseline<<"</text>";
}
void svg_rect(double x, double y, double width, double height,std::string stroke = "black", std::string fill = "green"){
std::cout<< "<rect x='"<< x <<"' y='"<< y <<"' width='"<< width <<"' height='"<< height <<"' stroke = '" << stroke <<"' fill = '" << fill <<"' />";
}
@ -55,7 +50,6 @@ show_histogram_svg(std::vector<size_t> bins,size_t max_count) {
const auto TEXT_LEFT_PROCENT = SCALE+TEXT_WIDTH+20;
svg_text(TEXT_LEFT, top + TEXT_BASELINE, std::to_string(bins[i]));
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT);
svg_proc(TEXT_LEFT_PROCENT, top + TEXT_BASELINE);
top += BIN_HEIGHT;
}}
@ -65,19 +59,9 @@ show_histogram_svg(std::vector<size_t> bins,size_t max_count) {
const auto TEXT_LEFT_PROCENT = (max_count*SCALE)+TEXT_WIDTH+20;
svg_text(TEXT_LEFT, top + TEXT_BASELINE, std::to_string(bins[i]));
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT);
svg_proc(TEXT_LEFT_PROCENT, top + TEXT_BASELINE);
top += BIN_HEIGHT;
}
svg_end();
}
/*for (size_t i = 0; i < bins.size(); i++) {
const 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);
svg_proc(BLOCK_WIDTH*bins[i]+TEXT_LEFT+50, top + TEXT_BASELINE,procent[i]);
top += BIN_HEIGHT;
}
svg_end();
}*/}

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