// Two-dimensional vector demonstration. CPP <br/> # include <vector> <br/> # include <algorithm> <br/> # include <iomanip> <br/> # include <iostream> <br/> using namespace STD; </P> <p> int main (void) <br/>{< br/> int X; // One-dimensional coordinate <br/> int y; // two-dimensional coordinates </P> <p> int I, j; </P> <p> cout <"enter two positive integers separated by spaces :"; <br/> CIN> x> Y; </P> <p> // defines a two-dimensional vector <br/> vector <int> my_array (X, vector <int> (y); </P> <p> for (I = 0; I <X; I ++) <br/> {<br/> for (j = 0; j <Y; j ++) <br/>{< br/> my_array [I] [J] = I + J; <br/>}</P> <p> for (I = 0; I <X; I ++) <br/> {<br/> for (j = 0; j <Y; j ++) <br/> {<br/> cout <SETW (6) <my_array [I] [J]; <br/>}< br/> cout <Endl; <br/>}</P> <p> return 0; <br/>}</P> <p> // 3D vector demonstration. CPP <br/> # pragma warning (Disable: 4786) </P> <p> # include <iostream> <br/> # include <iomanip> <br/> # include <vector> </P> <p> using namespace std; </P> <p> int main (void) <br/>{< br/> intx; // One-dimensional coordinate <br/> inty; // two-dimensional coordinates <br/> intz; // three-dimensional coordinates </P> <p> int I, J, K; </P> <p> cout <"Enter three positive integers separated by spaces:"; <br/> CIN> x> Y> Z; </P> <p> // define a three-dimensional vector <br/> vector <int> my_array (X, vector <vector <int> (Y, vector <int> (z); </P> <p> for (I = 0; I <X; I ++) <br/>{< br/> for (j = 0; j <Y; j ++) <br/> {<br/> for (k = 0; k <z; k ++) <br/> {<br/> my_array [I] [J] [k] = I + J + K; <br/>}</P> <p> for (I = 0; I <X; I ++) <br/> {<br/> for (j = 0; j <Y; j ++) <br/> {<br/> for (k = 0; k <z; k ++) <br/>{< br/> cout <SETW (6) <my_array [I] [J] [k]; <br/>}< br/> cout <Endl; <br/>}</P> <p> return 0; <br/>}< br/>