Сommit
						2400606aa0
					
				@ -0,0 +1,40 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
 | 
				
			||||||
 | 
					<CodeBlocks_project_file>
 | 
				
			||||||
 | 
						<FileVersion major="1" minor="6" />
 | 
				
			||||||
 | 
						<Project>
 | 
				
			||||||
 | 
							<Option title="lab-01" />
 | 
				
			||||||
 | 
							<Option pch_mode="2" />
 | 
				
			||||||
 | 
							<Option compiler="gcc" />
 | 
				
			||||||
 | 
							<Build>
 | 
				
			||||||
 | 
								<Target title="Debug">
 | 
				
			||||||
 | 
									<Option output="bin/Debug/lab-01" prefix_auto="1" extension_auto="1" />
 | 
				
			||||||
 | 
									<Option object_output="obj/Debug/" />
 | 
				
			||||||
 | 
									<Option type="1" />
 | 
				
			||||||
 | 
									<Option compiler="gcc" />
 | 
				
			||||||
 | 
									<Compiler>
 | 
				
			||||||
 | 
										<Add option="-g" />
 | 
				
			||||||
 | 
									</Compiler>
 | 
				
			||||||
 | 
								</Target>
 | 
				
			||||||
 | 
								<Target title="Release">
 | 
				
			||||||
 | 
									<Option output="bin/Release/lab-01" prefix_auto="1" extension_auto="1" />
 | 
				
			||||||
 | 
									<Option object_output="obj/Release/" />
 | 
				
			||||||
 | 
									<Option type="1" />
 | 
				
			||||||
 | 
									<Option compiler="gcc" />
 | 
				
			||||||
 | 
									<Compiler>
 | 
				
			||||||
 | 
										<Add option="-O2" />
 | 
				
			||||||
 | 
									</Compiler>
 | 
				
			||||||
 | 
									<Linker>
 | 
				
			||||||
 | 
										<Add option="-s" />
 | 
				
			||||||
 | 
									</Linker>
 | 
				
			||||||
 | 
								</Target>
 | 
				
			||||||
 | 
							</Build>
 | 
				
			||||||
 | 
							<Compiler>
 | 
				
			||||||
 | 
								<Add option="-Wall" />
 | 
				
			||||||
 | 
								<Add option="-fexceptions" />
 | 
				
			||||||
 | 
							</Compiler>
 | 
				
			||||||
 | 
							<Unit filename="main.cpp" />
 | 
				
			||||||
 | 
							<Extensions>
 | 
				
			||||||
 | 
								<lib_finder disable_auto="1" />
 | 
				
			||||||
 | 
							</Extensions>
 | 
				
			||||||
 | 
						</Project>
 | 
				
			||||||
 | 
					</CodeBlocks_project_file>
 | 
				
			||||||
@ -0,0 +1,102 @@
 | 
				
			|||||||
 | 
					#include <iostream>
 | 
				
			||||||
 | 
					#include <vector>
 | 
				
			||||||
 | 
					using namespace std;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int main()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						size_t numbers, columns, count;
 | 
				
			||||||
 | 
						float minn, maxx, diff, lo, hi;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						cerr << "Quantity of numbers = "; cin >> numbers;
 | 
				
			||||||
 | 
						vector<float> xs(numbers);
 | 
				
			||||||
 | 
						cerr << "Enter your numbers: ";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for (int i = 0; i < numbers; ++i)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							cin >> xs[i];
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						cerr << "Columns = "; cin >> columns;
 | 
				
			||||||
 | 
						vector<size_t> a(columns);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						maxx = xs[0];
 | 
				
			||||||
 | 
						minn = xs[0];
 | 
				
			||||||
 | 
						for (int i = 0; i < numbers; i++)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							if (xs[i] > maxx)
 | 
				
			||||||
 | 
								maxx = xs[i];
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								if (xs[i] < minn)
 | 
				
			||||||
 | 
									minn = xs[i];
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						diff = (maxx - minn) / columns;
 | 
				
			||||||
 | 
						lo = minn;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						size_t max_count = 0;
 | 
				
			||||||
 | 
						for (int i = 0; i < columns; ++i)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							count = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (i != columns - 1)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								hi = lo + diff;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								hi = maxx;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							for (int j = 0; j < numbers; j++)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								if (i == 0)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									if ((xs[j] >= lo) && (xs[j] <= hi))
 | 
				
			||||||
 | 
										count++;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									if ((xs[j] > lo) && (xs[j] <= hi))
 | 
				
			||||||
 | 
										count++;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							a[i] = count;
 | 
				
			||||||
 | 
							lo = hi;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (max_count < a[i])
 | 
				
			||||||
 | 
								max_count = a[i];
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						const size_t SCREEN_WIDTH = 80;
 | 
				
			||||||
 | 
						const size_t MAX_ASTERISK = SCREEN_WIDTH - 3 - 1;
 | 
				
			||||||
 | 
						size_t height;
 | 
				
			||||||
 | 
						for (int i = 0; i < columns; i++)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (a[i] == 0)
 | 
				
			||||||
 | 
								continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (a[i] < 10)
 | 
				
			||||||
 | 
								cout << "  ";
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
								if (a[i] < 100)
 | 
				
			||||||
 | 
									cout << " ";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							cout << a[i] << "|";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (max_count > MAX_ASTERISK)
 | 
				
			||||||
 | 
								height = MAX_ASTERISK * (static_cast<double>(a[i]) / max_count);
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
								height = a[i];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							for (int j = 0; j < height; j++)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								cout << "*";
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							cout << endl;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
					Загрузка…
					
					
				
		Ссылка в новой задаче