Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

How do I insert elements in a diagonal array c++?

+7 votes
asked Dec 3, 2021 by Mac (190 points)

2 Answers

+1 vote
answered Dec 6, 2021 by Peter Minarik (86,900 points)
edited Dec 7, 2021 by Peter Minarik

Typically you can insert elements at the end of an std::vector. For this, the push_back() function is used.

If you want to insert in any arbitrary position you can use the insert() function.

But to be honest, I'm not sure what you're after as the term "diagonal array" means nothing to me. Maybe you can explain what do you mean by that.

An array is a one-dimensional container where elements are located next to one another in the memory. If you want to visualize this as horizontal or vertical (or diagonal or spiral or whatever way), it's up to you.

[Element1][Element2][Element3]...[ElementN]
0 votes
answered Dec 7, 2021 by Areeb Sherjil (1,960 points)
Just like you would for a regular array.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...