1

I have written this code but I want to delete the route[mini][minj] and route[mini+1][minj] I want it to find the minimum every time delete that and find the minimum in others.

class Test {
public static void main(String[] args) {
    int x=3;
    int y=5;
    double d=0;
    double p=0;
    double min=1000;
    int mini=0;
    int minj=0;
    int b=0;
    int[][] route = new int[][]{
      {20,50,72,63,54,33,22,93,52,70},
      {67,56,46,37,39,29,15,11,13,71},
    };
    int[][] distance = new int[10][10];
    while (b<10) {
    for (int i=0;i<route.length-1;i++) {
        for (int j=0;j<route[0].length;j++) {
            distance[i][j]=route[i][j]-x;
            distance[i+1][j]=route[i+1][j]-y;
            p=Math.sqrt((distance[i][j])*(distance[i][j])+((distance[i+1][j])*(distance[i+1][j])));
            //System.out.println(p);
            if (min>=p) {
                min=p;
                mini=i;
                minj=j;
            }
        }
    }
    b++;
    }
}

} I searched for it but none of the answers seem to work for my situation.

Ghazal
  • 11
  • 2

1 Answers1

0
array = ArrayUtils.removeElement(array, element);

You can use above statement. There are plenty of posts on this topic.. search for it.. May be you will find ample of information on it..

XTR-Cold
  • 39
  • 3
  • I tried that but it didn't work. – Ghazal Apr 05 '15 at 06:19
  • Then you have to use Collection Framework like ArrayList or HashMap, They provide methods to remove elements. – XTR-Cold Apr 05 '15 at 06:41
  • I don't know how to do that – Ghazal Apr 05 '15 at 07:03
  • LINK: http://stackoverflow.com/questions/10477407/which-collection-is-better-to-store-data-from-multi-dimensional-array... For instance you can put a some INT val as a reserved value at position you want want to be shown as deleted. and then check for it and ignore the route while traversal.. – XTR-Cold Apr 06 '15 at 06:51