code: изменение
Этот коммит содержится в:
33
main.cpp
33
main.cpp
@@ -5,13 +5,14 @@ using namespace std;
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
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_ASTER = SCREEN_WIDTH - 3 - 1;
|
||||||
int i, j;
|
int i, j;
|
||||||
double num;
|
double num;
|
||||||
size_t number_count, bin_count;
|
size_t number_count, bin_count;
|
||||||
cerr << "Enter number count: " << "\n";
|
cerr << "Enter number count: " << "\n";
|
||||||
cin >> number_count;
|
cin >> number_count;
|
||||||
vector<double> numbers(number_count);
|
vector<double> numbers(number_count);
|
||||||
|
cerr << "Enter number: " << "\n";
|
||||||
for (i = 0; i < number_count; i++)
|
for (i = 0; i < number_count; i++)
|
||||||
{
|
{
|
||||||
cin >> num;
|
cin >> num;
|
||||||
@@ -26,6 +27,17 @@ int main()
|
|||||||
}
|
}
|
||||||
double min_number = numbers[0];
|
double min_number = numbers[0];
|
||||||
double max_number = numbers[0];
|
double max_number = numbers[0];
|
||||||
|
for (i = 1; i < bin_count, i++){
|
||||||
|
if (bins[i] < min_number)
|
||||||
|
{
|
||||||
|
min_number = bins[i];
|
||||||
|
}
|
||||||
|
else if (bins[i] > max_number)
|
||||||
|
{
|
||||||
|
max_number = bins[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (double x : numbers)
|
for (double x : numbers)
|
||||||
{
|
{
|
||||||
if (x < min_number)
|
if (x < min_number)
|
||||||
@@ -79,28 +91,17 @@ int main()
|
|||||||
{
|
{
|
||||||
cout << bins[i] << "|";
|
cout << bins[i] << "|";
|
||||||
}
|
}
|
||||||
if (bins[i] > 76){
|
if (bins[i] > MAX_ASTER){
|
||||||
height = MAX_ASTERISK * (static_cast<double>(bins[i]) / max_bin_capacity);
|
height = MAX_ASTER * (static_cast<double>(bins[i]) / max_bin_capacity);
|
||||||
}
|
}
|
||||||
else {
|
if (bins[i] < MAX_ASTER){
|
||||||
height = bins[i];
|
height = bins[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < height; j++)
|
for (j = 0; j < height; j++)
|
||||||
{
|
{
|
||||||
if (i > 0){
|
cout << "*";
|
||||||
if (j == bins[i-1] - 1){
|
|
||||||
cout<<"^";
|
|
||||||
}}
|
|
||||||
if (i < bin_count){
|
|
||||||
if (j == bins[i+1] - 1)
|
|
||||||
cout<<"v";
|
|
||||||
else
|
|
||||||
cout<<"*";}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
cout << "\n";
|
cout << "\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user