How to merge two arrays?
#include<iostream>
using namespace std;
int main()
{
int a1[5]={5,2,4,6,1};
int a2[5]={10,7,8,3,9};
int a3[10]={0};
int k=0;
for(int i=0;i<10;i++){
if(i>4){
a3[i]=a2[k++];
}
a3[i]=a1[i];
}
for(int j=0;j<10;j++){
cout<<a3[j]<<", ";
}
}
0 comments:
Post a Comment