Computer Scientists are Pretty Pessimistic

Tuesday, 1 March 2016

Use of 2D Vector in C++

#include <iostream>
#include <vector>
using namespace std;
int main ()
{
    vector<int>v[3];
    int i,j,val;
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            cin>>val;
            v[i].push_back(val);
        }
    }
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            cout<<v[i][j]<<" ";
        }
        cout<<"\n";
    }
}

No comments:

Post a Comment