|  |  |  | @ -3,13 +3,14 @@ | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | #include <iostream> | 
			
		
	
		
			
				
					|  |  |  |  | #include <vector> | 
			
		
	
		
			
				
					|  |  |  |  | #include <curl/curl.h> | 
			
		
	
		
			
				
					|  |  |  |  | #include "histogram.h" | 
			
		
	
		
			
				
					|  |  |  |  | #include "text.h" | 
			
		
	
		
			
				
					|  |  |  |  | #include "svg.h" | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | using namespace std; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | struct Input { | 
			
		
	
		
			
				
					|  |  |  |  | struct Input {                                                      //data input
 | 
			
		
	
		
			
				
					|  |  |  |  |     vector<double> numbers; | 
			
		
	
		
			
				
					|  |  |  |  |     size_t bin_count{}; | 
			
		
	
		
			
				
					|  |  |  |  |     size_t interval_task{}; | 
			
		
	
	
		
			
				
					|  |  |  | @ -17,35 +18,45 @@ struct Input { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | Input | 
			
		
	
		
			
				
					|  |  |  |  | input_data() { | 
			
		
	
		
			
				
					|  |  |  |  | input_data(istream& in, bool prompt) {                                                      //input data structure
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     if (prompt == false) {                                           //prompt output
 | 
			
		
	
		
			
				
					|  |  |  |  |         cerr.rdbuf(NULL); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     size_t number_count; | 
			
		
	
		
			
				
					|  |  |  |  |     cin >> number_count; | 
			
		
	
		
			
				
					|  |  |  |  |     cerr << "Enter number count: \n"; | 
			
		
	
		
			
				
					|  |  |  |  |     cerr.flush(); | 
			
		
	
		
			
				
					|  |  |  |  |     in >> number_count; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     Input in; | 
			
		
	
		
			
				
					|  |  |  |  |     Input in_data_struct; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     in.numbers.resize(number_count); | 
			
		
	
		
			
				
					|  |  |  |  |     in_data_struct.numbers.resize(number_count); | 
			
		
	
		
			
				
					|  |  |  |  |     for (size_t i = 0; i < number_count; i++) { | 
			
		
	
		
			
				
					|  |  |  |  |         cin >> in.numbers[i]; | 
			
		
	
		
			
				
					|  |  |  |  |         cerr << "Enter number "<< i << " : \n"; | 
			
		
	
		
			
				
					|  |  |  |  |         in >> in_data_struct.numbers[i]; | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     cin >> in.bin_count; | 
			
		
	
		
			
				
					|  |  |  |  |     cerr << "Enter bin count: \n"; | 
			
		
	
		
			
				
					|  |  |  |  |     in >> in_data_struct.bin_count; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     cin >> in.interval_task; | 
			
		
	
		
			
				
					|  |  |  |  |     cerr << "Enter interval from task: \n"; | 
			
		
	
		
			
				
					|  |  |  |  |     in >> in_data_struct.interval_task; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     if ((in.interval_task >= 2.0) && (in.interval_task <= 9.0)) { | 
			
		
	
		
			
				
					|  |  |  |  |         return in; | 
			
		
	
		
			
				
					|  |  |  |  |     if ((in_data_struct.interval_task >= 2.0) && (in_data_struct.interval_task <= 9.0)) {       //scale interval size check
 | 
			
		
	
		
			
				
					|  |  |  |  |         return in_data_struct; | 
			
		
	
		
			
				
					|  |  |  |  |     } else { | 
			
		
	
		
			
				
					|  |  |  |  |         std::cout << "ERROR"; | 
			
		
	
		
			
				
					|  |  |  |  |         std::cout << "ERROR";                                           //error situation and program exit
 | 
			
		
	
		
			
				
					|  |  |  |  |         exit(1); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | int main() { | 
			
		
	
		
			
				
					|  |  |  |  |     auto in = input_data(); | 
			
		
	
		
			
				
					|  |  |  |  |     auto bins = make_histogram(in.numbers, in.bin_count); | 
			
		
	
		
			
				
					|  |  |  |  |     show_histogram_svg(bins, in.interval_task); | 
			
		
	
		
			
				
					|  |  |  |  |     //curl_global_init(CURL_GLOBAL_ALL);
 | 
			
		
	
		
			
				
					|  |  |  |  |     auto in = input_data(cin, true);                                             //input data
 | 
			
		
	
		
			
				
					|  |  |  |  |     auto bins = make_histogram(in.numbers, in.bin_count);               //calculating bin size for the histogram
 | 
			
		
	
		
			
				
					|  |  |  |  |     show_histogram_svg(bins, in.interval_task);                         //histogram output in the format svg code
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     return 0; | 
			
		
	
		
			
				
					|  |  |  |  | } | 
			
		
	
	
		
			
				
					|  |  |  | 
 |