How do you define a triangular two-dimensional array using just vectors, not arrays or pointers? (C++)
#include <iostream>
#include <vector>
using namespace std;
int main(){
//1st way , store even the zeros
vector< vector<int> > triang1 = { {1, 0,
0, 0},
{2, 3, 0,
0},
{4, 5, 6,
0},
{7, 8, 9,
1}};
//2nd way not store zeros
vector< vector<int> > triang2 = {
{1},
{2, 3,
},
{4, 5,
6,},
{7, 8, 9,
1}};
return 0;
}
Get Answers For Free
Most questions answered within 1 hours.