| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -42,22 +42,22 @@ void find_minmax(const std::vector<double>& numbers, double &min, double &max)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					int main()
 | 
					 | 
					 | 
					 | 
					std::vector<size_t> make_histogram(const std::vector<double> &numbers, const size_t &bin_count)
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					{
 | 
					 | 
					 | 
					 | 
					{
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    Input in = input_data();
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    std::vector<size_t> bins(in.bin_count);
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    double min, max;
 | 
					 | 
					 | 
					 | 
					    double min, max;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    find_minmax(in.numbers, min, max);
 | 
					 | 
					 | 
					 | 
					    find_minmax(numbers, min, max);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    double bin_size = (max - min) / in.bin_count;
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    std::vector<size_t> bins(bin_count);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    double bin_size = (max - min) / bin_count;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    for (size_t i = 0; i < in.numbers.size(); i++)
 | 
					 | 
					 | 
					 | 
					    for (size_t i = 0; i < numbers.size(); i++)
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    {
 | 
					 | 
					 | 
					 | 
					    {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        bool found = false;
 | 
					 | 
					 | 
					 | 
					        bool found = false;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        for (size_t j = 0; (j < in.bin_count - 1) && !found; j++)
 | 
					 | 
					 | 
					 | 
					        for (size_t j = 0; (j < bin_count - 1) && !found; j++)
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        {
 | 
					 | 
					 | 
					 | 
					        {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            auto lo = min + j * bin_size;
 | 
					 | 
					 | 
					 | 
					            auto lo = min + j * bin_size;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            auto hi = min + (j + 1) * bin_size;
 | 
					 | 
					 | 
					 | 
					            auto hi = min + (j + 1) * bin_size;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if ((lo <= in.numbers[i]) && (in.numbers[i] < hi))
 | 
					 | 
					 | 
					 | 
					            if ((lo <= numbers[i]) && (numbers[i] <= hi))
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            {
 | 
					 | 
					 | 
					 | 
					            {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                bins[j]++;
 | 
					 | 
					 | 
					 | 
					                bins[j]++;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                found = true;
 | 
					 | 
					 | 
					 | 
					                found = true;
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -65,10 +65,14 @@ int main()
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					        }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (!found)
 | 
					 | 
					 | 
					 | 
					        if (!found)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        {
 | 
					 | 
					 | 
					 | 
					        {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            bins[in.bin_count - 1]++;
 | 
					 | 
					 | 
					 | 
					            bins[bin_count - 1]++;
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					        }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    return bins;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					void show_histogram_text(const std::vector<size_t> &bins, const std::vector<double> &numbers)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					{
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    const size_t SCREEN_WIDTH = 80;
 | 
					 | 
					 | 
					 | 
					    const size_t SCREEN_WIDTH = 80;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    const size_t MAX_ASTERISK = SCREEN_WIDTH - 5;
 | 
					 | 
					 | 
					 | 
					    const size_t MAX_ASTERISK = SCREEN_WIDTH - 5;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    size_t max_count = 0;
 | 
					 | 
					 | 
					 | 
					    size_t max_count = 0;
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -90,13 +94,13 @@ int main()
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            height = MAX_ASTERISK * (static_cast<double>(bin) / max_count);
 | 
					 | 
					 | 
					 | 
					            height = MAX_ASTERISK * (static_cast<double>(bin) / max_count);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					        }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        int fraction = bin * 100 / in.numbers.size();
 | 
					 | 
					 | 
					 | 
					        int fraction = bin * 100 / numbers.size();
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (fraction < 100)
 | 
					 | 
					 | 
					 | 
					        if (fraction < 100)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            std::cout << ' ';
 | 
					 | 
					 | 
					 | 
					            std::cout << ' ';
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (fraction < 10)
 | 
					 | 
					 | 
					 | 
					        if (fraction < 10)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            std::cout << ' ';
 | 
					 | 
					 | 
					 | 
					            std::cout << ' ';
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        std::cout << fraction << "%|";
 | 
					 | 
					 | 
					 | 
					        std::cout << fraction << "|";
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        for (size_t j = 0; j < height; j++)
 | 
					 | 
					 | 
					 | 
					        for (size_t j = 0; j < height; j++)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        {
 | 
					 | 
					 | 
					 | 
					        {
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -104,6 +108,12 @@ int main()
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					        }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        std::cout << std::endl;
 | 
					 | 
					 | 
					 | 
					        std::cout << std::endl;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					int main()
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					{
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    Input in = input_data();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    auto bins = make_histogram(in.numbers, in.bin_count);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    show_histogram_text(bins, in.numbers);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    return 0;
 | 
					 | 
					 | 
					 | 
					    return 0;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 |