remote87

Hanoi Towers Start

Dec 3rd, 2020 (edited)
565
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.company;
  2.  
  3. import java.util.Arrays;
  4. import java.util.Scanner;
  5.  
  6. public class Main {
  7.  
  8.     static int rings = 4;
  9.     static int[][] matrixMoves = new int[3][rings];
  10.  
  11.     public static void main(String args[])  {
  12.  
  13.  
  14.         System.out.println("празни кули 3 бр: " + Arrays.deepToString(matrixMoves));
  15.  
  16.         matrixMoves[0][0] = 1;
  17.         matrixMoves[0][1] = 2;
  18.         matrixMoves[0][2] = 3;
  19.         matrixMoves[0][3] = 4;
  20.  
  21.         //на пръчка едно има 4 ринга - 1 най - голям, 4 най - малък
  22.         System.out.println("1 кула с 4 ринга, празни кули 2 бр: " + Arrays.deepToString(matrixMoves));
  23.  
  24.         int counter = 1;
  25.         System.out.println("Начало: ");
  26.  
  27.         ///////////////// 1
  28.         matrixMoves[1][0] = matrixMoves[0][3];
  29.         matrixMoves[0][3] = 0;
  30.         System.out.println("Стъпка " + counter++ + " : " + Arrays.deepToString(matrixMoves) + "\n");
  31.         ///////////////// 2
  32.         matrixMoves[2][0] = matrixMoves[0][2];
  33.         matrixMoves[0][2] = 0;
  34.         System.out.println("Стъпка " + counter++ + " : " + Arrays.deepToString(matrixMoves) + "\n");
  35.         ///////////////// 3
  36.         matrixMoves[2][1] = matrixMoves[1][0];
  37.         matrixMoves[1][0] = 0;
  38.         System.out.println("Стъпка " + counter++ + " : " + Arrays.deepToString(matrixMoves) + "\n");
  39.         ///////////////// 4
  40.         matrixMoves[1][0] = matrixMoves[0][1];
  41.         matrixMoves[0][1] = 0;
  42.         System.out.println("Стъпка " + counter++ + " : " + Arrays.deepToString(matrixMoves) + "\n");
  43.         ///////////////// 5
  44.         matrixMoves[0][1] = matrixMoves[2][1];
  45.         matrixMoves[2][1] = 0;
  46.         System.out.println("Стъпка " + counter++ + " : " + Arrays.deepToString(matrixMoves) + "\n");
  47.         ///////////////// 6
  48.         matrixMoves[1][1] = matrixMoves[2][0];
  49.         matrixMoves[2][0] = 0;
  50.         System.out.println("Стъпка " + counter++ + " : " + Arrays.deepToString(matrixMoves) + "\n");
  51.         ///////////////// 7
  52.         matrixMoves[1][2] = matrixMoves[0][1];
  53.         matrixMoves[0][1] = 0;
  54.         System.out.println("Стъпка " + counter++ + " : " + Arrays.deepToString(matrixMoves) + "\n");
  55.         ///////////////// 8
  56.         matrixMoves[2][0] = matrixMoves[0][0];
  57.         matrixMoves[0][0] = 0;
  58.         System.out.println("Стъпка " + counter++ + " : " + Arrays.deepToString(matrixMoves) + "\n");
  59.         ///////////////// 9
  60.         matrixMoves[2][1] = matrixMoves[1][2];
  61.         matrixMoves[1][2] = 0;
  62.         System.out.println("Стъпка " + counter++ + " : " + Arrays.deepToString(matrixMoves) + "\n");
  63.         ///////////////// 10
  64.         matrixMoves[0][0] = matrixMoves[1][1];
  65.         matrixMoves[1][1] = 0;
  66.         System.out.println("Стъпка " + counter++ + " : " + Arrays.deepToString(matrixMoves) + "\n");
  67.         ///////////////// 11
  68.         matrixMoves[0][1] = matrixMoves[2][1];
  69.         matrixMoves[2][1] = 0;
  70.         System.out.println("Стъпка " + counter++ + " : " + Arrays.deepToString(matrixMoves) + "\n");
  71.         ///////////////// 12
  72.         matrixMoves[2][1] = matrixMoves[1][0];
  73.         matrixMoves[1][0] = 0;
  74.         System.out.println("Стъпка " + counter++ + " : " + Arrays.deepToString(matrixMoves) + "\n");
  75.         ///////////////// 13
  76.         matrixMoves[1][0] = matrixMoves[0][1];
  77.         matrixMoves[0][1] = 0;
  78.         System.out.println("Стъпка " + counter++ + " : " + Arrays.deepToString(matrixMoves) + "\n");
  79.         ///////////////// 14
  80.         matrixMoves[2][2] = matrixMoves[0][0];
  81.         matrixMoves[0][0] = 0;
  82.         System.out.println("Стъпка " + counter++ + " : " + Arrays.deepToString(matrixMoves) + "\n");
  83.         ///////////////// 15
  84.         matrixMoves[2][3] = matrixMoves[1][0];
  85.         matrixMoves[1][0] = 0;
  86.         System.out.println("Стъпка " + counter++ + " : " + Arrays.deepToString(matrixMoves) + "\n");
  87.     }
  88. }
RAW Paste Data