Vector <vector <int> 2D container Programming

Source: Internet
Author: User
# 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

Vector <vector <int> 2D container Programming

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.