Here I assume you are not learning algorithms about sorting.
After copying those elements into merg, write std::sort(merg, merg + 4);
You can find std::sort in header <algorithm>.
#include <iostream>
usingnamespace std;
int main()
{
int num [2];
int arra[2];
int merg[4];
cout <<"enter the numbers in your array (has have 2(two)numbers"<<endl;
for(int t=0;t<2; t++)
{
cout<<t<<":";
cin>>arra[t];
}
cout <<"enter the numbers in your second array (has have 2(two)numbers"<<endl;
for(int t=0;t<2; t++)
{
cout<<t<<":";
cin>>num[t];
}
merg[0]=arra[0];
merg[1]=arra[1];
merg[2]=num[0];
merg[3]=num[1];
for(int o=0; o<4;o++)
{
cout<<merg[o]<<", ";
}
int ary [4];
ary[0]=merg[0];
ary[1]=merg[1];
ary[2]=merg[2];
ary[3]=merg[3];
int swp [4];
int i=0,help;
int length;
while(i<length-1){
if(arra[i]>arra[i+1]){
help=arra[i];
arra[i]=arra[i+1];
arra[i+1]=help;
}
i++;
for (int t=0; t<4; i++)
{
cout<<arra[t]<<",";
}
}
return 0;
}
but that doesn't work, if I type in 2,1,4,3 it shows 2,1,3,4 . if there are two same numbers, then it doesn't work