在C语言中,可以通过使用循环遍历的方法合并两个数组。具体步骤如下:
#define SIZE1 10
#define SIZE2 5
#define SIZE3 5
int result[SIZE1];
int arr1[SIZE2] = {1, 2, 3, 4, 5};
int arr2[SIZE3] = {6, 7, 8, 9, 10};
int i;
for (i = 0; i < SIZE2; i++) {
result[i] = arr1[i];
}
for (i = SIZE2; i < SIZE1; i++) {
result[i] = arr2[i - SIZE2];
}
最后,合并后的结果就存储在result数组中。
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: C语言中nanosleep函数的用法是什么