|
|
|
@ -15,7 +15,6 @@ using namespace std;
|
|
|
|
|
struct Input {
|
|
|
|
|
vector<double> numbers;
|
|
|
|
|
size_t bin_count{};
|
|
|
|
|
float n;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Input
|
|
|
|
@ -33,19 +32,10 @@ input_data(istream& in,bool prompt) {
|
|
|
|
|
Input on;
|
|
|
|
|
on.numbers.resize(number_count);
|
|
|
|
|
for (size_t i = 0; i < number_count; i++) {
|
|
|
|
|
cerr << b << i+1 << ": ";
|
|
|
|
|
//cerr << b << i+1 << ": ";
|
|
|
|
|
in >> on.numbers[i];}
|
|
|
|
|
cerr << c;
|
|
|
|
|
in >> on.bin_count;
|
|
|
|
|
|
|
|
|
|
on.n = 0;
|
|
|
|
|
if (on.bin_count==0){
|
|
|
|
|
on.bin_count = sqrt(number_count);
|
|
|
|
|
on.n = 1;
|
|
|
|
|
if (on.bin_count > 25){
|
|
|
|
|
on.bin_count = 1 + log2(number_count);
|
|
|
|
|
on.n = 2;}}
|
|
|
|
|
|
|
|
|
|
return on;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -80,12 +70,55 @@ download(const string& address) {
|
|
|
|
|
|
|
|
|
|
int main(int argc, char* argv[]){
|
|
|
|
|
Input input;
|
|
|
|
|
|
|
|
|
|
if (argc > 1) {
|
|
|
|
|
input = download(argv[1]);}
|
|
|
|
|
string adr, format, type;
|
|
|
|
|
if ((adr=argv[1]).substr(0,7)!= "http://"){
|
|
|
|
|
if ((format=argv[1])== "-format"){
|
|
|
|
|
if ((type=argv[2])== "svg"){
|
|
|
|
|
input = download(argv[3]);
|
|
|
|
|
const auto bins = make_histogram(input.numbers, input.bin_count);
|
|
|
|
|
show_histogram_svg(bins);
|
|
|
|
|
}
|
|
|
|
|
else if ((type=argv[2])== "text"){
|
|
|
|
|
input = download(argv[3]);
|
|
|
|
|
|
|
|
|
|
auto bins = make_histogram(input.numbers, input.bin_count);
|
|
|
|
|
show_histogram_text(bins, input.bin_count);}
|
|
|
|
|
else
|
|
|
|
|
cerr << "wrong type";}}
|
|
|
|
|
else{
|
|
|
|
|
input = input_data(cin, true);}
|
|
|
|
|
if ((format=argv[2])== "-format"){
|
|
|
|
|
if (argc ==3)
|
|
|
|
|
cerr << "wrong type";
|
|
|
|
|
else
|
|
|
|
|
if ((type=argv[3])== "svg"){
|
|
|
|
|
input = download(argv[1]);
|
|
|
|
|
const auto bins = make_histogram(input.numbers, input.bin_count);
|
|
|
|
|
show_histogram_svg(bins);}
|
|
|
|
|
|
|
|
|
|
else if ((type=argv[3])== "text"){
|
|
|
|
|
input = download(argv[1]);
|
|
|
|
|
|
|
|
|
|
auto bins = make_histogram(input.numbers, input.bin_count);
|
|
|
|
|
show_histogram_text(bins, input.bin_count);}
|
|
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//auto bins = make_histogram(in.numbers, in.bin_count);
|
|
|
|
|
//show_histogram_text(bins, in.bin_count, in.n);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*if ((adr=argv[1]).substr(0,7)== "http://"){
|
|
|
|
|
input = download(argv[1]);
|
|
|
|
|
if ((type=argv[2])== "svg"){
|
|
|
|
|
const auto bins = make_histogram(input.numbers, input.bin_count);
|
|
|
|
|
show_histogram_svg(bins);}*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const auto bins = make_histogram(input);
|
|
|
|
|
show_histogram_svg(bins);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|