Dark_Tranquillity
08-07-2004, 14:02
qualcuno mi convertirebbe le due funzioni iterative elencate sotto in funzioni ricorsive:
void copy (int *b, int *c, int *j, int n, int *k)
{
int h;
for (h=*j;h<=n;h++)
{
c[*k]=b[h];
*k=*k+1;
}
}
void shortmerge (int *a, int *b, int *c, int m, int *j, int *k)
{
int l;
l=0;
while (l<=m)
{
if (a[l]<=b[*j])
{
c[*k]=a[l];
l=l+1;
}
else
{
c[*k]=b[*j];
*j=*j+1;
}
*k=*k+1;
}
}
void copy (int *b, int *c, int *j, int n, int *k)
{
int h;
for (h=*j;h<=n;h++)
{
c[*k]=b[h];
*k=*k+1;
}
}
void shortmerge (int *a, int *b, int *c, int m, int *j, int *k)
{
int l;
l=0;
while (l<=m)
{
if (a[l]<=b[*j])
{
c[*k]=a[l];
l=l+1;
}
else
{
c[*k]=b[*j];
*j=*j+1;
}
*k=*k+1;
}
}