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
)
)
请采纳谢谢!
插入元素必须需要数组元素要比元素个数多,给出如下例:#include <iostream>
using namespace std
int main()
{
int arr[100]//声明数组;
int n
cout<<"请输入元素的个数:"
cin>>n//有多少个数组元素
cout<<"请输入元素:"
for(int i=0i<ni++)
{
cin>>arr[i]
}
sort(arr,arr+n)//对数组进行从小到大排序
cout<<"请输入要插入的元素"<<endl
cin>>arr[n]
sort(arr,arr+n+1)//对插入的元素进行从小到大排序
cout<<"排序后的元素:"
for(int i=0i<ni++)
{
cout<<arr[i]<<" "
}
cout<<arr[n]<<endl
return 0
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)