Guest User

Untitled

a guest
Apr 26th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. package javaapplication26;
  6.  
  7. import java.util.Scanner;
  8.  
  9. /**
  10. *
  11. * @author Maria
  12. */
  13. public class JavaApplication26 {
  14.  
  15. public static void main(String[] args) {
  16. Scanner S = new Scanner(System.in);
  17.  
  18.  
  19. int[][] pole;
  20. pole = new int[8][8];
  21. int i;
  22. int j;
  23. for (i = 0; i < 8; i++) {
  24. for (j = 0; j < 8; j++) {
  25. pole[i][j] = 0;
  26. }
  27. }
  28.  
  29. for (i = 0; i < 3; i++) {
  30. for (j = 0; j < 4; j++) {
  31. pole[i][2 * j + 1 - i % 2] = 1;
  32. }
  33. }
  34.  
  35. for (i = 5; i < 8; i++) {
  36. for (j = 0; j < 4; j++) {
  37. pole[i][2 * j + 1 - i % 2] = 2;
  38. }
  39. }
  40.  
  41. int n, m, k, p;
  42. System.out.println("put in the initial and final position");
  43. n = S.nextInt();
  44. m = S.nextInt();
  45. p = S.nextInt();
  46. k = S.nextInt();
  47.  
  48. if (n - 1 < 0 || m - 1 < 0 || n + 1 > 7 || m + 1 > 7) {
  49. System.out.println("put in the correct data");
  50. }
  51.  
  52. if (pole[n][m] == 1 && p == n + 1 && k == m + 1 || k == m - 1) {
  53. pole[n][m] = 0;
  54. pole[p][k] = 1;
  55. }
  56.  
  57. if (pole[n][m] == 2 && p == n - 1 && k == m + 1 || k == m - 1) {
  58. pole[n][m] = 0;
  59. pole[p][k] = 2;
  60. } else {
  61. System.out.println("not correct data");
  62. }
  63. for (i = 0; i < 8; i++) {
  64. for (j = 0; j < 8; j++) {
  65.  
  66. if (pole[0][2 * j + 1 - i % 2] == 2) {
  67. System.out.print("@");
  68. }
  69. if (pole[7][2 * 2 * j + 1 - i % 2] == 1) {
  70. System.out.print("*");
  71. }
  72. if (pole[i][j] == 1) {
  73. System.out.print("+");
  74. }
  75. if (pole[i][j] == 2) {
  76. System.out.print("o");
  77. }
  78. if (pole[i][j] == 0) {
  79. System.out.print("Z");
  80.  
  81. }
  82.  
  83. }
  84. System.out.println();
  85. }
  86.  
  87. }
  88. }
Add Comment
Please, Sign In to add comment