R
R
Ruslan2020-10-12 13:35:09
C++ / C#
Ruslan, 2020-10-12 13:35:09

How to make an array if you don't know its size c++?

The task is to calculate all the values ​​​​of the function y with x from n to n2, in order to then collect it all into an array and find out which of the elements is the maximum. And so, a question:
1. How to create an array if you do not know its length?
2. How to calculate the maximum element from this?
the first question worries me more, I searched in Google, I did not find answers there

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Pavlov, 2020-10-12
@ruprup


A vector in C++
is a replacement for a standard dynamic array, for which memory is allocated manually using the new operator.
The language developers recommend using vector instead of manually allocating memory for an array. This avoids memory leaks and makes the programmer's job easier.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question