有序表归并算法

#include"iostream"
#include   <time.h>  
using namespace std;
struct Sqlist
{
int data[100];
int length;
};
void merge(Sqlist l1,Sqlist l2,Sqlist& l3)
{
int i = 0, j = 0, k = 0;
while (i != l1.length&&j != l2.length)
{
if (l1.data[i] > l2.data[j])
{
l3.data[k] = l2.data[j];
k++; j++;
}
else
{
l3.data[k] = l1.data[i];
k++; i++;
}
}
while (i < l1.length)
{
l3.data[k] = l1.data[i];
k++; j++;
}
while (j < l2.length)
{
l3.data[k] = l2.data[j];
k++; j++;
}
l3.length = k;
}
int main()
{
Sqlist l1; l1.length = 3; l1.data[0] = 1; l1.data[1] = 3; l1.data[2] = 5;
Sqlist l2; l2.length = 3; l2.data[0] = 2; l2.data[1] = 4; l2.data[2] = 6;
Sqlist l3;
merge(l1, l2, l3);
for (int i = 0; i < 6; i++)
{
cout<<l3.data[i]<<" ";
}
return 0;
}

;