master
Родитель
b09f674990
Сommit
8ea1724db0
@ -1,5 +1,4 @@
|
|||||||
bin/
|
bin/
|
||||||
cs-lab34.cbp
|
|
||||||
cs-lab34.depend
|
cs-lab34.depend
|
||||||
obj/
|
obj/
|
||||||
|
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||||
|
<CodeBlocks_project_file>
|
||||||
|
<FileVersion major="1" minor="6" />
|
||||||
|
<Project>
|
||||||
|
<Option title="cs-lab34" />
|
||||||
|
<Option pch_mode="2" />
|
||||||
|
<Option compiler="gcc" />
|
||||||
|
<Build>
|
||||||
|
<Target title="Debug">
|
||||||
|
<Option output="bin/Debug/cs-lab34" 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/cs-lab34" 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>
|
@ -1,5 +1,4 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
void static find_minmax(vector<double> vec, double& min, double& max);
|
|
||||||
vector<size_t> make_histogram(size_t number, vector<double> vec);
|
vector<size_t> make_histogram(size_t number, vector<double> vec);
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
void find_minmax(std::vector<double> vec, double& min, double& max);
|
@ -0,0 +1,83 @@
|
|||||||
|
#include "text.h"
|
||||||
|
|
||||||
|
void show_histogram(std::vector<size_t> bins) {
|
||||||
|
bool gigant = false;
|
||||||
|
auto spaces = 0;
|
||||||
|
size_t mx_count = 0;
|
||||||
|
for (auto x : bins) {
|
||||||
|
if (x > 76) {
|
||||||
|
gigant = true;
|
||||||
|
}
|
||||||
|
if (x > mx_count) {
|
||||||
|
mx_count = x;
|
||||||
|
}
|
||||||
|
auto len = 0;
|
||||||
|
while (x > 0) {
|
||||||
|
x /= 10;
|
||||||
|
len++;
|
||||||
|
}
|
||||||
|
if (len > spaces) {
|
||||||
|
spaces = len;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (spaces == 1) {
|
||||||
|
for (size_t i = 0; i < bins.size(); i++) {
|
||||||
|
std::cout << " " << bins[i] << "|";
|
||||||
|
if (gigant) {
|
||||||
|
if (bins[i] == mx_count) {
|
||||||
|
for (size_t j = 0; j < 76; j++) {
|
||||||
|
std::cout << "*";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (size_t j = 0; j < 76 * static_cast<double>(bins[i]) / mx_count; j++) {
|
||||||
|
std::cout << "*";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (size_t j = 0; j < bins[i]; j++) {
|
||||||
|
std::cout << "*";
|
||||||
|
}
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < bins.size(); i++) {
|
||||||
|
int len = 1;
|
||||||
|
int k = bins[i];
|
||||||
|
for (; k /= 10; ++len);
|
||||||
|
while (len < spaces) {
|
||||||
|
std::cout << " ";
|
||||||
|
len++;
|
||||||
|
}
|
||||||
|
std::cout << bins[i];
|
||||||
|
std::cout << "|";
|
||||||
|
if (gigant) {
|
||||||
|
if (bins[i] == mx_count) {
|
||||||
|
for (size_t j = 0; j < 76; j++) {
|
||||||
|
std::cout << "*";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (size_t j = 0; j < (76 * static_cast<double>(bins[i]) / mx_count - 1); j++) {
|
||||||
|
std::cout << "*";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (size_t j = 0; j < bins[i]; j++) {
|
||||||
|
std::cout << "*";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
void show_histogram(std::vector<size_t> bins);
|
Загрузка…
Ссылка в новой задаче