请问,我的程序有什么问题
package JAVAStack;import *;
import java.math.*;
public class NewQueue {
private int maxsize;
private int queues[];
private int front;
private int rear;
private int nelements;
public NewQueue(int maxvalue){
maxsize=maxvalue;
queues=new int[maxsize];
front =0;
rear=-1;
nelements=0;
}
public boolean isEmpty(){
return (nelements==0);
}
public boolean isFull(){
return (nelements==maxsize);
}
public void insert(int x){
int s=0;
if(!isFull()){
queues[++rear]=x;
nelements++;
if(nelements>1){
/* for(int i=0;i<=rear;i++)
for(int j=0;j<=rear;j++) {
if((queues[i]>queues[j])&&(i<j)){
s=queues[i];
queues[i]=queues[j];
queues[j]=s;
}
} */
}
}
}
public void remove(){
int deletevalue=0;
if(!isEmpty()){
deletevalue=queues[front++];
nelements--;
}
}
public void display(){
int temp=0;
for(temp=front;temp<=rear;temp++){
if(temp==rear)
System.out.print(queues[temp]+".");
else
System.out.print(queues[temp]+",");
}
}
public void wrap(int insex1,int insex2){
int temp=0;
temp=queues[insex1];
queues[insex1]=queues[insex2];
queues[insex2]=temp;
}
public void quickSort(int left ,int right){
if(right-left>=1){
int pivotx=queues[right];
int partionitx=partionit(left,right,pivotx);
quickSort(left,partionitx-1);
quickSort(partionitx+1,right);
}
}
public int partionit(int leftx,int rightx,int pivot){
int left1=leftx-1;
int right1=rightx+1;
int pivot1=pivot;
while(true){
while(queues[++left1]<pivot1);
while(queues[--right1]>pivot1);
if(left1>=right1)
break;
else
wrap(left1,right1);
}
return left1;
}
public void sort(){
quickSort(0,nelements-1);
}
public static void main(String args[]) throws IOException{
NewQueue nq=new NewQueue(30);
int t=(int)(Math.random()*100);
int t1=(int)(Math.random()*100);
int t2=(int)(Math.random()*100);
int t3=(int)(Math.random()*100);
nq.insert(20);
nq.insert(10);
nq.insert(5);
nq.insert(5);
nq.insert(3);
nq.insert(3);
nq.insert(6);
nq.insert(6);
nq.insert(20);
nq.insert(20);
nq.insert(t);
nq.insert(t1);
nq.insert(t2);
nq.insert(t3);
nq.display();
System.out.print("\n");
nq.sort();;
nq.display();
}
}
这是个快速排序法的例子
但是执行的时候有时正确有时出错,请帮我看看粗了什么问题,谢谢!