#include <bits/stdc++.h>
using namespace std;
int main() {
array<vector<int>,10>arr1;
arr1[0].push_back(1);
arr1[0].push_back(2);
arr1[0].push_back(3);
arr1[1].push_back(4);
arr1[1].push_back(5);
arr1[2].push_back(6);
arr1[7].push_back(100);
for(auto i:arr1) {
for(auto j :i)
cout<<j<<" ";cout<<"\n";
}
}
I'm creating array of vectors and pushing some values and I can't figure out how to make remaining places zeros.
I have an idea , first making all vectors inside each array inside to hold zeros of size 10. and instead of using push_back
, I will use at()
.
But I need code to make vectors inside array zeros for size 10.
output :
1 2 3
4 5
6
100
Q2)
what is difference between
array<vector<int>,10>arr;
and
vector<int> arr[10];