# Include <iostream> # include <vector> Using STD: cout; Using STD: Endl; Using STD: vector; template <typename T> void show (const vector <t> & ivvec); // outputs the int main (void) content of the vector <int>) {vector <int> ivvec; // 10 columns in five rows for (INT I = 0; I <5; ++ I) {vector <int> ivec; // create a temporary vector <int> to store the row data of a two-dimensional vector (Int J = 0; j <10; ++ J) {ivec. push_back (j);} ivvec. push_back (ivec); // Add vector <int> (add row data) ivec. Clear (); // Delete ivec data} cout <ivvec. size () <Endl; // output 5 show (ivvec); Return exit_success;} template <typename T> void show (const vector <t> & ivvec) {for (STD: vector <t> >:: const_iterator iter = ivvec. begin (); iter! = Ivvec. end (); ++ ITER) // you must add STD: {for (STD: vector <t >:: const_iterator it = ITER-> begin (); it! = ITER-> end (); ++ it) // you must add STD ::{ cout <* It <"" ;}cout <Endl ;} // You can also write/* For (INT I = 0; I <ivvec. size (); ++ I) {// vector <int> ivec = ivvec [I]; for (Int J = 0; j <ivvec [I]. size (); ++ J) {cout <ivvec [I] [J] <";}cout <Endl ;}*/}
This article is from the "whatever957" blog, please be sure to keep this source http://whatever957.blog.51cto.com/6835003/1570377
Vector <vector <int> 2D container Programming