// using vector of vectors as multidimentional arrayx // Mikhail Nesterenko // 4/12/2013 #include #include using std::cin; using std::cout; using std::endl; using std::vector; int main (){ cout << "Enter row size: "; int width; cin >> width; vector row(width); cout << "Enter number of rows: "; int length; cin >> length; vector> a; // creating a multidimentional array // by entering rows into a vector for(int i=0; i < length; ++i) a.push_back(row); // initializes the array for(int i=0; i < length; ++i) for(int j=0; j < width; ++j) a[i][j] = i*width+j; // output each array element's value for (int i=0; i < length; ++i) for (int j=0; j < width; ++j) cout << "a[" << i << "][" << j << "] = " << a[i][j]<< endl; }