|  |  |  | @ -0,0 +1,65 @@ | 
			
		
	
		
			
				
					|  |  |  |  | #include <vector> | 
			
		
	
		
			
				
					|  |  |  |  | #include <iostream> | 
			
		
	
		
			
				
					|  |  |  |  | using namespace std; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | int main() { | 
			
		
	
		
			
				
					|  |  |  |  | 	const size_t SCREEN_WIDTH = 80; | 
			
		
	
		
			
				
					|  |  |  |  | 	const size_t MAX_ASTERISK = SCREEN_WIDTH - 3 - 1; | 
			
		
	
		
			
				
					|  |  |  |  | 	int i,j; | 
			
		
	
		
			
				
					|  |  |  |  | 	string a,b,c; | 
			
		
	
		
			
				
					|  |  |  |  | 	size_t number_count, bin_count; | 
			
		
	
		
			
				
					|  |  |  |  | 	cerr << "Enter number count: "; | 
			
		
	
		
			
				
					|  |  |  |  | 	cin >> number_count; | 
			
		
	
		
			
				
					|  |  |  |  | 	cerr << "Enter colichestvo corzin: "; | 
			
		
	
		
			
				
					|  |  |  |  | 	cin >> bin_count; | 
			
		
	
		
			
				
					|  |  |  |  | 	vector <size_t> bins(bin_count); | 
			
		
	
		
			
				
					|  |  |  |  | 	vector <double> numbers(number_count); | 
			
		
	
		
			
				
					|  |  |  |  | 	for (i = 0; i < number_count; i++) { | 
			
		
	
		
			
				
					|  |  |  |  | 		cin >> numbers[i]; | 
			
		
	
		
			
				
					|  |  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  |  | 	double min = numbers[0]; | 
			
		
	
		
			
				
					|  |  |  |  | 	double max = numbers[0]; | 
			
		
	
		
			
				
					|  |  |  |  | 	for (double x : numbers) { | 
			
		
	
		
			
				
					|  |  |  |  | 		if (x < min) { | 
			
		
	
		
			
				
					|  |  |  |  | 			min = x; | 
			
		
	
		
			
				
					|  |  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  |  | 		else if (x > max) { | 
			
		
	
		
			
				
					|  |  |  |  | 			max = x; | 
			
		
	
		
			
				
					|  |  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  |  | 	double bin_size = (max - min) / bin_count; | 
			
		
	
		
			
				
					|  |  |  |  | 	for (size_t i = 0; i < number_count; i++) { | 
			
		
	
		
			
				
					|  |  |  |  | 		bool found = false; | 
			
		
	
		
			
				
					|  |  |  |  | 		for (size_t j = 0; (j < bin_count - 1) && !found; j++) { | 
			
		
	
		
			
				
					|  |  |  |  | 			double lo = min + j * bin_size; | 
			
		
	
		
			
				
					|  |  |  |  | 			double hi = min + (j + 1) * bin_size; | 
			
		
	
		
			
				
					|  |  |  |  | 			if ((lo <= numbers[i]) && (numbers[i] < hi)) { | 
			
		
	
		
			
				
					|  |  |  |  | 				bins[j]++; | 
			
		
	
		
			
				
					|  |  |  |  | 				found = true; | 
			
		
	
		
			
				
					|  |  |  |  | 			} | 
			
		
	
		
			
				
					|  |  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  |  | 		if (!found) { | 
			
		
	
		
			
				
					|  |  |  |  | 			bins[bin_count - 1]++; | 
			
		
	
		
			
				
					|  |  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  |  | 	int maxlen = 0; | 
			
		
	
		
			
				
					|  |  |  |  | 	for (int j = 0; j < bin_count; j++) | 
			
		
	
		
			
				
					|  |  |  |  | 	{ | 
			
		
	
		
			
				
					|  |  |  |  | 		if (maxlen < bins[j]) maxlen = bins[j]; | 
			
		
	
		
			
				
					|  |  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  |  | 	for (int j = 0; j < bin_count; j++) | 
			
		
	
		
			
				
					|  |  |  |  | 	{ | 
			
		
	
		
			
				
					|  |  |  |  | 		if (bins[j] < 100) cout << " "; | 
			
		
	
		
			
				
					|  |  |  |  | 		if (bins[j] < 10) cout << " "; | 
			
		
	
		
			
				
					|  |  |  |  | 		cout << bins[j] << "|"; | 
			
		
	
		
			
				
					|  |  |  |  | 		size_t height = bins[j]; | 
			
		
	
		
			
				
					|  |  |  |  | 		if (maxlen > MAX_ASTERISK) | 
			
		
	
		
			
				
					|  |  |  |  | 		{ | 
			
		
	
		
			
				
					|  |  |  |  | 			if (maxlen != bins[j]) height = MAX_ASTERISK * (static_cast<float>(bins[j]) / maxlen); | 
			
		
	
		
			
				
					|  |  |  |  | 			else if (maxlen == bins[j]) height = MAX_ASTERISK; | 
			
		
	
		
			
				
					|  |  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  |  | 		for (int i = 0; i < height; i++) cout << "*"; | 
			
		
	
		
			
				
					|  |  |  |  | 		cout << "\n"; | 
			
		
	
		
			
				
					|  |  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  |  | 	return 0; | 
			
		
	
		
			
				
					|  |  |  |  | } |