اينو من برا خودم نوشتم مي ذارم شايد بدردتون بخوره:5:
کد:
#include <iostream>
using namespace std;
int* sort(int* one,int* two,int of1,int of2)
{
int* result;
result = new int[of1 + of2];
int i = 0;
for(i = 0;i < of1;i++)
result[i] = one[i];
for(int a = of1,b = 0;a < (of1 + of2) && b < of2;a++,b++)
result[a] = two[b];
int item;
for(i = 0;i < (of1 + of2);i++)
for(int j = 0;j <= i;j++)
if(result[j] > result[i])
{
item = result[i];
result[i] = result[j];
result[j] = item;
}
return result;
}
int main()
{
int* one,*two,*result,of1,of2;
cout <<"enter offset of array one:";
cin>>of1;
cout <<"\nenter offset of array two:";
cin>>of2;
one = new int[of1];
two = new int[of2];
for(int i = 0;i < of1;i++)
{
cout <<"\none["<<i<<"]:";
cin>>one[i];
}
for(int j = 0;j < of2;j++)
{
cout <<"\ntwo["<<j<<"]:";
cin>>two[j];
}
result = new int[of1 + of2];
int h = 0;
result = sort(one,two,of1,of2);
for(int k = 0;k < (of1 + of2);k++)
cout <<result[k]<<endl;
return 0;
}