|  |  | @ -8,116 +8,73 @@ using namespace std; | 
			
		
	
		
		
			
				
					
					|  |  |  | const size_t SCREEN_WIDTH = 80; |  |  |  | const size_t SCREEN_WIDTH = 80; | 
			
		
	
		
		
			
				
					
					|  |  |  | const size_t MAX_ASTERISK = SCREEN_WIDTH - 3 - 1; |  |  |  | const size_t MAX_ASTERISK = SCREEN_WIDTH - 3 - 1; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | int main() { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	size_t numbersCount; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	cerr << "Number count ==>"; cin >> numbersCount; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	vector<double> numbers(numbersCount); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	size_t binCount; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	bool running; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	int res; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	running =true; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	res = 0; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	size_t i, j, min, max; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	cerr << "Numbers ==>"; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	for (i = 0; i < numbersCount; i++) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		cin >> numbers[i]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | struct Input |  |  |  | 	while (running) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | { |  |  |  |     { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     vector<double> numbers; |  |  |  | 	cerr << "Bin count ==>"; cin >> binCount; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     size_t bin_count{}; |  |  |  | 	vector<size_t> bins(binCount); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | }; |  |  |  | 	min = numbers[0]; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | Input |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | input_data(){ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     cerr << "Input numbers count: "; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     size_t number_count; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     cin >> number_count; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     Input in; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     in.numbers.resize(number_count); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     cerr << "Input numbers: "; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     for (size_t i = 0; i < number_count; i++) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         cin >> in.numbers[i]; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     cerr << "Input bin count: "; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     cin >> in.bin_count; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     return in; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | void |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | find_minmax(vector<double> numbers, double &min, double &max) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     min = numbers[0]; |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 	max = numbers[0]; |  |  |  | 	max = numbers[0]; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	for (size_t i = 1; i < numbers.size(); i++) |  |  |  | 	for (i = 1; i < numbersCount; i++) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         { |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 		if (min > numbers[i]) |  |  |  | 		if (min > numbers[i]) | 
			
		
	
		
		
			
				
					
					|  |  |  | 			min = numbers[i]; |  |  |  | 			min = numbers[i]; | 
			
		
	
		
		
			
				
					
					|  |  |  | 		if (max < numbers[i]) |  |  |  | 		if (max < numbers[i]) | 
			
		
	
		
		
			
				
					
					|  |  |  | 			max = numbers[i]; |  |  |  | 			max = numbers[i]; | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  | 	} | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         return; |  |  |  | 	double binSize = (max - min) / (float) binCount; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | 	for (i = 0; i < numbersCount; i++) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | vector <size_t> make_histogramm(vector<double>numbers, size_t bin_count) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     double min, max; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     find_minmax(numbers, min, max); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     double binSize = (max - min) / bin_count; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     vector<size_t> bins(bin_count); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	for (size_t i = 0; i < numbers.size(); i++) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	{ |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 		bool found = false; |  |  |  | 		bool found = false; | 
			
		
	
		
		
			
				
					
					|  |  |  | 		for (size_t j = 0; (j <= bin_count - 1) && !found; j++) |  |  |  | 		for (j = 0; (j < binCount - 1) && !found; j++) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		{ |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 			auto lo = min + j * binSize; |  |  |  | 			auto lo = min + j * binSize; | 
			
		
	
		
		
			
				
					
					|  |  |  | 			auto hi = min + (j + 1) * binSize; |  |  |  | 			auto hi = min + (j + 1) * binSize; | 
			
		
	
		
		
			
				
					
					|  |  |  | 			if ((lo <= numbers[i]) && (numbers[i] < hi)) |  |  |  | 			if ((lo <= numbers[i]) && (numbers[i] < hi)) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 			{ |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 				bins[j]++; |  |  |  | 				bins[j]++; | 
			
		
	
		
		
			
				
					
					|  |  |  | 				found = true; |  |  |  | 				found = true; | 
			
		
	
		
		
			
				
					
					|  |  |  | 			} |  |  |  | 			} | 
			
		
	
		
		
			
				
					
					|  |  |  | 		} |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  | 		if (!found) |  |  |  | 		if (!found) | 
			
		
	
		
		
			
				
					
					|  |  |  | 			bins[bin_count - 1]++; |  |  |  | 			bins[binCount - 1]++; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 	size_t max_count = bins[0]; |  |  |  | 	size_t max_count = 0; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	for (size_t i = 0; i < bin_count; i++) |  |  |  | 	for (i = 0; i < binCount; i++) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	{ |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 		if (max_count < bins[i]) |  |  |  | 		if (max_count < bins[i]) | 
			
		
	
		
		
			
				
					
					|  |  |  | 			max_count = bins[i]; |  |  |  | 			max_count = bins[i]; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 	if (max_count > 76) { |  |  |  | 	for (i = 0; i < binCount; i++) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         for (size_t i = 0; i < bin_count; i++) { |  |  |  | 		if (bins[i] < 100) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             int count = bins[i]; |  |  |  | 			cout << " "; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             size_t height = 76 * (static_cast<double>(count) / max_count); |  |  |  | 		if (bins[i] < 10) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             bins[i] = height; |  |  |  | 			cout << " "; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  | 		cout << bins[i]; | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		cout << "|"; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		size_t count = bins[i]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		size_t height = 76 * (static_cast<double>(count) / max_count); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		for (j = 0; j < bins[i]; j++){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			if (j < height) //3 ýòàï
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				cout << "*"; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			else | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				break; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		cout << endl; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	cout << "R u satisfied?    " << "1)yeeeeeesss      2)nooooooooo" << endl; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	cin >> res; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	if (res == 1) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         running = false; | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |     return bins; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | void show_histogramm(vector<size_t>bins) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     for (size_t i = 0; i < bins.size(); i++) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         cout << bins[i] << "|"; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         for (size_t j = 0; j < bins[i]; j++) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             cout << "*"; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         cout << endl; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     return; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | int main() |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     /*bool running;
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	int res; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	running =true; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	res = 0;*/ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	Input in = input_data(); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	auto bins = make_histogramm(in.numbers, in.bin_count); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	show_histogramm(bins); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	return 0; |  |  |  | 	return 0; | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
	
		
		
			
				
					|  |  | 
 |