一维给二维赋值,参考实例如下:
for (i = 0; i < 10; i++)
{
for (j = 0; j < max; j++)
{
scanf("%d", &a[j]);
}
strncpy(b[i], a, max);
//memcpy(b[i], a, max);
}
二维数组赋值有两种方法,
第一种方法是单元格区域装入二维数组,如:
Arr=range("a1:b19")就可以把单元格区域的值装入数组arr
第二种就是通过循环装入,一个个数值装入。
例:
向二维数组写入数据和读取;
Dim x As Integer, y As Integer
Dim arr(1 To 5, 1 To 4)
For x = 1 To 5
你说的太抽象了,给你一个实例:
Dim a(), b(), arr(1, 4)
a = Array(1, 3, 5, 7, 9)
b = Array(2, 4, 6, 8, 10)
For i = 0 To 4
arr(0, i) = a(i)
arr(1, i) = b(i)
Next
for i = 1 to ubound(数组1)
arr(1,i) = 数组1(i)
next i
for i = 1 to ubound(数组1)
arr(2,i) = 数组2(i)
next i
dim arr1,arr2,arr3(),smax&,r%
arr1=array(1,2,3,4)
arr2=array(5,6,7,8)
smax=application.max(ubound(arr1),ubound(arr2))
redim arr3(1 to smax,1 to 2)
for r=1 to smax
if r<= ubound(arr1) then arr3(r,1)=arr1(r)
if r<=ubound(arr2) then arr3(r,2)=arr2(r)
next r
仅供参考