Advertisement
Lusien_Lashans

Laba part 2

Mar 24th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.49 KB | None | 0 0
  1. import java.util.ArrayList;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.         int count = 6;
  7.  
  8.         int[][] arr,orr;
  9.  
  10.         arr = new int[][]{
  11.                 {2,3,0},
  12.                 {1,4,0},
  13.                 {1,0},
  14.                 {2,0},
  15.                 {6,0},
  16.                 {5,0},
  17.         };
  18.  
  19.         orr = new int[][]{
  20.                 {1,2},
  21.                 {1,3},
  22.                 {1,4},
  23.                 {4,8},
  24.                 {8,7},
  25.                 {5,6},
  26.         };
  27.  
  28.         System.out.println(" ");
  29.  
  30.         ArrayList<Integer> list = new ArrayList<Integer>();
  31.         list.add(0,1);
  32.         list.add(1,2);
  33.         int n = 1;
  34.         for (int j=0; j<orr.length; j++){
  35.             if (list.indexOf(orr[j][0]) == -1){
  36.                 KS++;
  37.                 n++;
  38.                 list.add(n,0);
  39.                 n++;
  40.                 list.add(n,orr[j][0]);
  41.                 n++;
  42.                 list.add(n,orr[j][1]);
  43.             }
  44.             else if (list.indexOf(orr[j][1]) == -1){
  45.                 n++;
  46.                 list.add(n,orr[j][1]);
  47.             }
  48.         }
  49.         System.out.println(list);
  50.     }
  51.         public static void EnteringArray(int count, int[][] arr){
  52.             for (int i=0; i<count; i++){
  53.                 System.out.println(" ");
  54.                 for(int j=0; j<arr[i].length; j++){
  55.                     System.out.print(arr[i][j]);
  56.                 }
  57.             }
  58.         }
  59.     public static int KS = 1;
  60.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement