// When using C language or CPP to create an array, a large number of new and delete operations are used, which is unpleasant.
// Use <array> instead. It is very convenient. It is the same as STL <vector>.
// Execution efficiency is higher than <vector>, which is almost the same as int myarray [5 ].
// Save the following code as testarray. cpp, In the UTF-8 format, compiled using mingw:
// G ++ testarray. cpp-STD = C ++ 0x
Http://blog.csdn.net/rumswell/article/details/7338025
# Include <iostream> # include <array> using namespace STD; int main () {// ------------------------------------------------- // -- this is a one-dimensional array <int, 5> myarray = {1, 2, 3, 4, 5}; // --------------------------------------------- cout <"myarray =" <Endl; For (size_t n = 0; n <myarray. size (); N ++) {cout <myarray [N] <'\ T';} cout <Endl; // --------------------------------------------- // you can also use cout <"myarray =" <Endl; For (size_t n = 0; n <myarray. size (); N ++) {cout <myarray. at (n) <'\ T';} cout <Endl; // ----------------------------------------------------- // This is a two-dimensional array with three rows and two columns in total <array <int, 2>, 3> myarray2d = {1, 2, 4, 5, 6}; // export cout <"myarray2d =" <Endl; For (size_t m = 0; m <myarray2d. size (); m ++) {for (size_t n = 0; n <myarray2d [M]. size (); N ++) {cout <myarray2d [m] [N] <'\ t' ;}cout <Endl; // ------------------------------------------------- return 0 ;}