array(1,2,3),
array("a","b","c")
)
$arr[]=array(11,22,33)
print_r($arr)
这是输出的结果!
Array(
[0] =>Array
(
[0] =>1
[1] =>2
[2] =>3
)
[1] =>Array
(
[0] =>a
[1] =>b
[2] =>c
)
[2] =>Array
(
[0] =>11
[1] =>22
[2] =>33
)
)
请采纳谢谢!
很简单利用C语言中的动态数组就可以搞定
举个例子
#include <stdio.h>#include <stdlib.h>
#include <malloc.h>
#include <time.h>
int main()
{
srand((unsigned)time(NULL))
int n
int new_number
printf("please input a number:\n")
scanf("%d",&n)
int *p = (int *)malloc(n*sizeof(int))
for (int i=0i<ni++)
{
p[i] = rand()%100
}
printf("the array is:\n")
for (int i=0i<ni++)
{
printf("%d\t",p[i])
}
printf("add a new number to array:\n")
scanf("%d",&new_number)
int *q = (int *)realloc(p,(n+1)*sizeof(int))
q[n] = new_number
printf("after add a new number the array is:\n")
for (int i=0i<n+1i++)
{
printf("%d\t",q[i])
}
free(q)
system("pause")
return 0
}
通过动态数组就可以在原本已经满的数组后面继续添加元素
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)