c++:
一維數(shù)組:
1压语,int arr[5];
2搁廓,//a如果初始化數(shù)據(jù)的時(shí)候沒有全部填完财著,會(huì)用0補(bǔ)全
int arr[4] = { 1,3,5,7 };
3,//暫時(shí)不定義長(zhǎng)度沦童,但是大括號(hào)里面不可為空
int arr[] = { 1,2,3,4 };
定義數(shù)組必須定義長(zhǎng)度
獲取數(shù)組長(zhǎng)度sizeof(arr)/sizeof(aar[0])
sizeof()獲取數(shù)組元素個(gè)數(shù)int 類型 長(zhǎng)度
二維數(shù)組:
int aar[2][3];
int aar[2][3]={
{1,2,3}仑濒,
{4,5,6}
}
int aar[2][3]={1,2,3,4,5,6}
int aar[][3]={1,2,3,4,5,6}
java:
一維數(shù)組:
1, int[] arr = new int[3];
2, int[] arr = new int[]{1,2,3,4,5};
3, int[] arr = {1,2,3,4,5};
獲取數(shù)組長(zhǎng)度arr.length
二維數(shù)組:
int[][] arr3 = new int[3][3];
int[][] arr = {
{10,20,30,100},
{40,50,60,110},
{70,80,90,120}
};