//************************************************************************
// A C++ program to provide examples of the use of multi-dimensional 
// vectors with the C++ standard template library
//
// Author: Sherry Towers
//         smtowers@asu.edu
// Created: Feb 13th, 2013
//
// Copyright Sherry Towers, 2013
//
// This program is not guaranteed to be free of bugs and/or errors.
//
// This program can be freely used and shared, as long as the author information
// and copyright in the header remains intact.
//************************************************************************
#include <iostream>
#include <vector>   // need this to use vectors
using namespace std;

//************************************************************************
//************************************************************************
//************************************************************************
int main (){
  vector< vector <double> > mvt;  // creates an empty 2D vector
 
  // create a ragged arrary of 10 rows
  cout << endl;
  for (int i=0;i<10;i++){
     vector<double> v;
     cout << "Row " << i+1 << " of the mvt vector: ";
     for (int j=0;j<=i;j++){
        v.push_back(j);
        cout << j << " "; 
     }
     cout << endl;
     mvt.push_back(v);
  }
  cout << endl;


  cout << "The number of rows of the mvt vector is " 
       << mvt.size() << endl;
  cout << "The length of the fourth row of the mvt vector is " 
       << mvt[3].size() << endl;
  cout << "The value of the third row and second column is "
       << mvt[2][1] << endl;
  cout << endl;

  vector< vector <vector <double> > > mvt3d;  // creates an empty 3D vector
  mvt3d.push_back(mvt);
  mvt3d.push_back(mvt);
  mvt3d.push_back(mvt);
  cout << "The [2,5,3]th element of mvt3d is " << mvt3d[1][4][2] << endl;

  mvt.clear();
  mvt3d.clear();
  cout << endl;


  return 0;
}

