code: Индивидуальное задание

main
YusufovYB 2 лет назад
Родитель 5447a773e7
Сommit 4fbe7d24cf

@ -1,3 +1,4 @@
#include "svg.h"
#include <string>
using namespace std;
@ -47,19 +48,42 @@ void show_histogram_svg(const vector<size_t> &bins){
if (bin > max_count)
max_count = bin;
}
const auto BLOCK_WIDTH = (IMAGE_WIDTH - TEXT_WIDTH) / max_count;
cout << "Block_wight=";
double BLOCK_WIDTH;
cin >> BLOCK_WIDTH;
bool prov=1;
if((BLOCK_WIDTH<3) || (BLOCK_WIDTH>30)){
prov=0;
while(prov==0){
cout<< "Error range from 3 to 30 pi" << endl;
cout<< "Block_wight=";
cin >> BLOCK_WIDTH;
if((BLOCK_WIDTH>3) && (BLOCK_WIDTH<30) ){
prov=1;
}
}
}
for (size_t bin : bins)
{
const double bin_width = BLOCK_WIDTH * bin;
svg_text(TEXT_LEFT, top + TEXT_BASELINE, std::to_string(bin));
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "blue", "#aaffaa");
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, "blue", "green");
top += BIN_HEIGHT;
}
// svg_text(20, 20, std::to_string(bins[0]));
// svg_rect(50, 0, bins[0] * 10, 30);
svg_end();
}

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