#include<iostream>
#include<vector>
using namespace std;
int main()
{
vector<vector<int> > a;
int n, m, c, i, j;
cout << "Enter Row and Column :: ";
cin >> n >> m;
for(i=0;i<n;i++)
{
vector < int > b;
for(j=0;j<m;j++)
{
cin >> c;
b.push_back(c);
}
a.push_back(b);
}
cout << "2D Vector is :: " << endl;
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
cout << a[i][j] << " ";
}
cout << endl;
}
return 0;
}
#include<vector>
using namespace std;
int main()
{
vector<vector<int> > a;
int n, m, c, i, j;
cout << "Enter Row and Column :: ";
cin >> n >> m;
for(i=0;i<n;i++)
{
vector < int > b;
for(j=0;j<m;j++)
{
cin >> c;
b.push_back(c);
}
a.push_back(b);
}
cout << "2D Vector is :: " << endl;
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
cout << a[i][j] << " ";
}
cout << endl;
}
return 0;
}
Comments
Post a Comment