1. Member
Join Date
Nov 2010
Posts
3
Rep Power
0

Metacode to JAVA

Hi I have a meta code

I try to convert it for the JAVA, and it wouldn't work, can anybody help me ?

PHP Code:
```public static void QuickSortSplit(float E[])
{
int m=0; int n=E.length;

m=split(E);
if(m>1)
{
//QuickSortSplit(E[0..m-1]);
float[] temp=new float[m];
System.arraycopy(E, 0, temp, 0, m);

QuickSortSplit(temp);
System.arraycopy(temp,0,E,0,m);
}
if((n-m-1)>1)
{

//QuickSortSplit(E[m+1..n-1]);
float[] temp=new float[n-m];
for(int i=0; i<n-m; i++)
temp[i]=E[m+i];

QuickSortSplit(temp);
for(int i=0; i<n-m; i++)
E[m+1+i]=temp[i];
QuickSortSplit(E);
}
}
public static int split(float E[])
{
int l=1;
int r=E.length-1;
float tmp;
while(l<=r)
{
while((l<=r) && (E[r]>E[0])) r=r-1;
while((l<=r) && (E[l]<E[0])) l=l+1;
if(l<r)
{
tmp = E[l];
E[l] = E[r];
E[r] = tmp;
l=l+1;
r=r-1;
}
}
if(r>0) {
tmp = E[0];
E[0] = E[r];
E[r] = tmp;
}
return r;
}```

2. Senior Member
Join Date
Dec 2009
Posts
104
Rep Power
0
Please tell us which errors you get?

3. Member
Join Date
Nov 2010
Posts
3
Rep Power
0
When I try 3 elements array with: 1,2,3 the loop never end, but it works for the array 3,2,1

This is a complete code, you can try to compile this for any example array
Last edited by woser; 11-07-2010 at 04:28 PM.

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•