Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package javaapplication26;
- import java.util.Scanner;
- /**
- *
- * @author Maria
- */
- public class JavaApplication26 {
- public static void main(String[] args) {
- Scanner S = new Scanner(System.in);
- int[][] pole;
- pole = new int[8][8];
- int i;
- int j;
- for (i = 0; i < 8; i++) {
- for (j = 0; j < 8; j++) {
- pole[i][j] = 0;
- }
- }
- for (i = 0; i < 3; i++) {
- for (j = 0; j < 4; j++) {
- pole[i][2 * j + 1 - i % 2] = 1;
- }
- }
- for (i = 5; i < 8; i++) {
- for (j = 0; j < 4; j++) {
- pole[i][2 * j + 1 - i % 2] = 2;
- }
- }
- int n, m, k, p;
- System.out.println("put in the initial and final position");
- n = S.nextInt();
- m = S.nextInt();
- p = S.nextInt();
- k = S.nextInt();
- if (n - 1 < 0 || m - 1 < 0 || n + 1 > 7 || m + 1 > 7) {
- System.out.println("put in the correct data");
- }
- if (pole[n][m] == 1 && p == n + 1 && k == m + 1 || k == m - 1) {
- pole[n][m] = 0;
- pole[p][k] = 1;
- }
- if (pole[n][m] == 2 && p == n - 1 && k == m + 1 || k == m - 1) {
- pole[n][m] = 0;
- pole[p][k] = 2;
- } else {
- System.out.println("not correct data");
- }
- for (i = 0; i < 8; i++) {
- for (j = 0; j < 8; j++) {
- if (pole[0][2 * j + 1 - i % 2] == 2) {
- System.out.print("@");
- }
- if (pole[7][2 * 2 * j + 1 - i % 2] == 1) {
- System.out.print("*");
- }
- if (pole[i][j] == 1) {
- System.out.print("+");
- }
- if (pole[i][j] == 2) {
- System.out.print("o");
- }
- if (pole[i][j] == 0) {
- System.out.print("Z");
- }
- }
- System.out.println();
- }
- }
- }
Add Comment
Please, Sign In to add comment