Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- public class Main {
- public static void main(String[] args) {
- int count = 6;
- int[][] arr,orr;
- arr = new int[][]{
- {2,3,0},
- {1,4,0},
- {1,0},
- {2,0},
- {6,0},
- {5,0},
- };
- orr = new int[][]{
- {1,2},
- {1,3},
- {1,4},
- {4,8},
- {8,7},
- {5,6},
- };
- System.out.println(" ");
- ArrayList<Integer> list = new ArrayList<Integer>();
- list.add(0,1);
- list.add(1,2);
- int n = 1;
- for (int j=0; j<orr.length; j++){
- if (list.indexOf(orr[j][0]) == -1){
- KS++;
- n++;
- list.add(n,0);
- n++;
- list.add(n,orr[j][0]);
- n++;
- list.add(n,orr[j][1]);
- }
- else if (list.indexOf(orr[j][1]) == -1){
- n++;
- list.add(n,orr[j][1]);
- }
- }
- System.out.println(list);
- }
- public static void EnteringArray(int count, int[][] arr){
- for (int i=0; i<count; i++){
- System.out.println(" ");
- for(int j=0; j<arr[i].length; j++){
- System.out.print(arr[i][j]);
- }
- }
- }
- public static int KS = 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement