Родитель
							
								
									9628dec71f
								
							
						
					
					
						Сommit
						bd29d25837
					
				| @ -0,0 +1,32 @@ | |||||||
|  | #include <iostream> | ||||||
|  | #include <cmath> | ||||||
|  | #include <vector> | ||||||
|  | #include "text.h" | ||||||
|  | using namespace std; | ||||||
|  | 
 | ||||||
|  | void show_histogram_text(const vector<size_t>& bins, size_t &bin_count) | ||||||
|  | { | ||||||
|  | const size_t SCREEN_WIDTH = 80; | ||||||
|  | const size_t MAX_ASTERISK = SCREEN_WIDTH - 3 - 1; | ||||||
|  | 
 | ||||||
|  | size_t max_bin = bins[0]; | ||||||
|  | for (size_t bin : bins) | ||||||
|  | if (bin > max_bin) | ||||||
|  | max_bin = bin; | ||||||
|  | for (size_t bin : bins) | ||||||
|  | { | ||||||
|  | int height = bin; | ||||||
|  | if (max_bin > MAX_ASTERISK) | ||||||
|  | { | ||||||
|  | height = MAX_ASTERISK * (static_cast<double>(bin) / max_bin); | ||||||
|  | } | ||||||
|  | if (bin < 100) | ||||||
|  | cout << " "; | ||||||
|  | if (bin < 10) | ||||||
|  | cout << " "; | ||||||
|  | cout << bin << "|"; | ||||||
|  | for (int i = 0; i < height; i++) | ||||||
|  | cout << "*"; | ||||||
|  | cout << endl; | ||||||
|  | } | ||||||
|  | } | ||||||
					Загрузка…
					
					
				
		Ссылка в новой задаче