این کد رو امتحان کن:
#include<iostream>
using namespace std;
void main()
{
int a[]={0,5,7,9,14,25,30,41,51,200};
int b[]={10,21,32,33,35,40,54,101,198,201};
int c[20];
int l=0,k=0;
for(int i=0;i<(sizeof(a)+sizeof(b))/sizeof(int);i++)
{
if(a[k]<b[l] && k<(sizeof(a)/sizeof(int)))
{
c[k+l]=a[k];
k++;
}
else if(l<(sizeof(b)/sizeof(int)))
{
c[k+l]=b[l];
l++;
}
else
{
c[k+l]=a[k];
k++;
}
}
for(int i=0;i<(sizeof(a)+sizeof(b))/sizeof(int);i++)
cout<<(int)c[i]<<" , ";
system("pause>nul");
}
Don't Expect Anyone Except Yourself,...