Distance between uset input numbers in a 2d array java -


i'm beginner programmer , need 2dimensional arrays. program has read how many rows , columns there in array(it's square so, numbers same , set "d" in program below), , has read number "n" tells program how many inputs there in array. then, user adds "n" numbers array , output needs distance between input numbers (the distance between first , second, second , third,...). have move manhattan distance.

int d=sc.nextint(); int n=sc.nextint();  int[][] array=new int[d][d]; //length , heigth of array  int distance=0; int c=0; for(int i=0;i>d;i++){     for(int j=0;j>d;j++){         array[i][j]=c;         c++;          distance=math.abs(i)+math.abs(j);     }  } system.out.println(distance); 

this have far. need filling code part sums distances , prints it. ty


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -