Skip to content

Comments

Shvachko hm4#45

Open
z0r0vich wants to merge 9 commits intomainfrom
Shvachko_HM4
Open

Shvachko hm4#45
z0r0vich wants to merge 9 commits intomainfrom
Shvachko_HM4

Conversation

@z0r0vich
Copy link
Collaborator

No description provided.

@z0r0vich z0r0vich changed the title Shvachko hm4 Shvachko hm5 Nov 22, 2020
@z0r0vich z0r0vich changed the title Shvachko hm5 Shvachko hm4 Nov 23, 2020
public:
Array() //конструктор без параметров
{
size = 1;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

зачем size в один элемент?

Array() //конструктор без параметров
{
size = 1;
arr = new int[size];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
arr = new int[size];
arr = new int[size]{};

вам не нужно будет писать ниже цикл

Array(int s) //конструктор с одним параметром
{
size = s;
arr = new int[size];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это вынесите в список инициализации

Array(const Array &source) //конструктор копирования
{
size = source.size;
arr = new int[size];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

эти две строки вынесите в список инициализации


void set() //ввод случайных элементов массива
{
srand(time(0));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше nullptr вместо 0, time просто принимает указатель


void sort() //сортировка массива по возрастанию
{
int temp;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

думаю что лучше эту переменную внести внутри цикла

}
}
int max() {
sort();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не думаю что соритировка это хорошая идея для получения максимального элемента, т.е. я вызываю метод max а по итогу мы сортируем массив

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants