1 //11-Array. cpp: The entry point that defines the console application. 2 //3 4#include"stdafx.h"5#include <iostream>6#include <climits>7 using namespacestd;8 //An array is a composite type that can store multiple data of the same type. 9 intMain ()Ten { One A Charcarray[Ten]; - BOOLbarray[ -]; - floatfarray[ the]; the Doubledarray[ -]; - intscorearray1[4] = { the, -,623, the};//the array is declared and initialized, and the array contains 20 data of type int. - intscorearray2[4] = { the, the};//the remaining unassigned values are assigned by default. - intScorearray3[] = { the, -,245,123, $,1, *,};//How many elements are added, and how long the array will be. + //the Declaration and assignment of an array must be made in the same row, or an error will occur. - //an array of arrays cannot be assigned to each other. + A //the newest way to initialize C + + at intscorearray4[4]{ at, $, the,123,};//c++11 allows the "=" of the above three ways to be removed. - - //find the corresponding data by index (subscript) of the array. The index starts at 0. -cout << scorearray1[0] << Endl;//Do not access the non-existent index, access to the non-existent index program will not error, will provide an unknown data. -cout << scorearray2[1] <<Endl; -cout << scorearray3[3] <<Endl; incout << scorearray4[2] <<Endl; - toscorearray1[1] = -;//replaces the value corresponding to the specified index in the array. + - intT; theCin>>T; * return 0; $}
Fundamentals of C + + programming 111-Arrays