|
|
@ -2,6 +2,7 @@
|
|
|
|
#include <math.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <iostream>
|
|
|
|
#include <iostream>
|
|
|
|
#include <conio.h>
|
|
|
|
#include <conio.h>
|
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
#include "histogram.h"
|
|
|
|
#include "histogram.h"
|
|
|
|
#include "text.h"
|
|
|
|
#include "text.h"
|
|
|
|
#include "svg.h"
|
|
|
|
#include "svg.h"
|
|
|
@ -11,22 +12,32 @@ struct Input {
|
|
|
|
size_t bin_count{};
|
|
|
|
size_t bin_count{};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
Input
|
|
|
|
Input
|
|
|
|
input_data(istream& in){
|
|
|
|
input_data(istream& in, bool prompt){
|
|
|
|
|
|
|
|
cerr << "Do you need hints? Type 0 for no, 1 for yes: ";
|
|
|
|
|
|
|
|
int ans;
|
|
|
|
|
|
|
|
int state = 0;
|
|
|
|
|
|
|
|
while (state ==0){
|
|
|
|
|
|
|
|
in >> ans;
|
|
|
|
|
|
|
|
if (ans==1) {prompt = true; state=1;}
|
|
|
|
|
|
|
|
else if (ans==0) {prompt = false; state=1;}
|
|
|
|
|
|
|
|
else cerr << "Invalid data. Please type only 0 or 1: ";
|
|
|
|
|
|
|
|
}
|
|
|
|
size_t number_count;
|
|
|
|
size_t number_count;
|
|
|
|
cerr << "Enter number count: ";
|
|
|
|
if (prompt == true) cerr << "Enter number count: ";
|
|
|
|
in >> number_count;
|
|
|
|
in >> number_count;
|
|
|
|
Input input;
|
|
|
|
Input input;
|
|
|
|
input.numbers.resize(number_count);
|
|
|
|
input.numbers.resize(number_count);
|
|
|
|
cerr << "Enter numbers: ";
|
|
|
|
if (prompt == true) cerr << "Enter numbers: ";
|
|
|
|
for (size_t i = 0; i < number_count; i++){
|
|
|
|
for (size_t i = 0; i < number_count; i++){
|
|
|
|
in >> input.numbers[i];
|
|
|
|
in >> input.numbers[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cerr << "Enter bin count: ";
|
|
|
|
if (prompt == true) cerr << "Enter bin count: ";
|
|
|
|
in >> input.bin_count;
|
|
|
|
in >> input.bin_count;
|
|
|
|
return input;
|
|
|
|
return input;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int main(){
|
|
|
|
int main(){
|
|
|
|
auto in = input_data(cin);
|
|
|
|
bool prompt;
|
|
|
|
|
|
|
|
auto in = input_data(cin, prompt);
|
|
|
|
auto bins = make_histogram(in.numbers, in.bin_count);
|
|
|
|
auto bins = make_histogram(in.numbers, in.bin_count);
|
|
|
|
show_histogram_svg(bins);
|
|
|
|
show_histogram_svg(bins);
|
|
|
|
}
|
|
|
|
}
|
|
|
|