package com.company;
class mergeNumbers {
public static void mergeNumbers(int[][] grid, int row, int column, int nextNumber) {
grid = new int[][]{
{2, 0, 1, 1, 0, 8},
{2, 1, 0, 2, 4, 0},
{1, 2, 1, 2, 1, 3},
{2, 3, 2, 0, 1, 0},
{0, 0, 5, 8, 7, 2},
{2, 0, 1, 1, 0, 0}};
}
}
//电路板的单元格为空或包含数字。
答案 0 :(得分:0)
package com.company;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int[][] puma = {{1, 2, 0, 3}, {3, 2, 0, 1}, {0, 0, 4, 2}, {3, 3, 0, 4}};
Scanner input = new Scanner(System.in);
System.out.println("Enter space for putting 1: ");
int a = input.nextInt();
int b = input.nextInt();
if (a == 0 && b == 2) {
puma[0][2] = 1;
for (a = 0; a < puma.length; a++) {
for (b = 0; b < puma[0].length; b++) {
System.out.print(puma[a][b] + " ");
}
System.out.print('\n');
}
System.out.println("Enter space for putting 2: ");
a = input.nextInt();
b = input.nextInt();
if (a == 1 && b == 2) {
puma[1][2] = 2;
for (a = 0; a < puma.length; a++) {
for (b = 0; b < puma[0].length; b++) {
System.out.print(puma[a][b] + " ");
}
System.out.print('\n');
}
System.out.println("Enter space for putting 3: ");
a = input.nextInt();
b = input.nextInt();
if (a == 2 && b == 0) {
puma[2][0] = 3;
for (a = 0; a < puma.length; a++) {
for (b = 0; b < puma[0].length; b++) {
System.out.print(puma[a][b] + " ");
}
System.out.print('\n');
}
System.out.println("Enter space for putting 1: ");
a = input.nextInt();
b = input.nextInt();
if (a == 2 && b == 1) {
puma[2][1] = 1;
for (a = 0; a < puma.length; a++) {
for (b = 0; b < puma[0].length; b++) {
System.out.print(puma[a][b] + " ");
}
System.out.print('\n');
}
System.out.println("Enter space for putting 2: ");
a = input.nextInt();
b = input.nextInt();
if (a == 3 && b == 2) {
puma[3][2] = 2;
for (a = 0; a < puma.length; a++) {
for (b = 0; b < puma[0].length; b++) {
System.out.print(puma[a][b] + " ");
}
System.out.print('\n');
}
}
if (a == 3 && b == 2) {
puma[3][2] = 1;
for (a = 0; a < puma.length; a++) {
for (b = 0; b < puma[0].length; b++) {
System.out.print(puma[a][b] + " ");
}
System.out.print('\n');
}
System.out.println("Enter space for putting 2: ");
a = input.nextInt();
b = input.nextInt();
if (a == 2 && b == 1) {
puma[2][1] = 2;
for (a = 0; a < puma.length; a++) {
for (b = 0; b < puma[0].length; b++) {
System.out.print(puma[a][b] + " ");
}
System.out.print('\n');
}
}
}
}
if (a == 2 && b == 1) {
puma[2][1] = 3;
for (a = 0; a < puma.length; a++) {
for (b = 0; b < puma[0].length; b++) {
System.out.print(puma[a][b] + " ");
}
System.out.print('\n');
}
System.out.println("Enter space for putting 1: ");
a = input.nextInt();
b = input.nextInt();
if (a == 2 && b == 0) {
puma[2][0] = 1;
for (a = 0; a < puma.length; a++) {
for (b = 0; b < puma[0].length; b++) {
System.out.print(puma[a][b] + " ");
}
System.out.print('\n');
}
System.out.println("Enter space for putting 2: ");
a = input.nextInt();
b = input.nextInt();
if (a == 3 && b == 2) {
puma[3][2] = 2;
}
}
if (a == 3 && b == 2) {
puma[3][2] = 1;
for (a = 0; a < puma.length; a++) {
for (b = 0; b < puma[0].length; b++) {
System.out.print(puma[a][b] + " ");
}
System.out.print('\n');
}
System.out.println("Enter space for putting 2: ");
a = input.nextInt();
b = input.nextInt();
if (a == 2 && b == 0) {
puma[2][0] = 2;
}
}
}
if (a == 3 && b == 2) {
puma[3][2] = 3;
for (a = 0; a < puma.length; a++) {
for (b = 0; b < puma[0].length; b++) {
System.out.print(puma[a][b] + " ");
}
System.out.print('\n');
}
System.out.println("Enter space for putting 1: ");
a = input.nextInt();
b = input.nextInt();
}
}
if (a == 2 && b == 0) {
puma[2][0] = 2;
for (a = 0; a < puma.length; a++) {
for (b = 0; b < puma[0].length; b++) {
System.out.print(puma[a][b] + " ");
}
System.out.print('\n');
}
System.out.println("Enter space for putting 3: ");
a = input.nextInt();
b = input.nextInt();
if (a == 1 && b == 2) {
puma[1][2] = 3;
}
if (a == 2 && b == 1) {
puma[2][1] = 3;
}
if (a == 3 && b == 2) {
puma[3][2] = 3;
}
}
if (a == 2 && b == 1) {
puma[2][1] = 2;
for (a = 0; a < puma.length; a++) {
for (b = 0; b < puma[0].length; b++) {
System.out.print(puma[a][b] + " ");
}
System.out.print('\n');
}
System.out.println("Enter space for putting 3: ");
a = input.nextInt();
b = input.nextInt();
if (a == 1 && b == 2) {
puma[1][2] = 3;
}
if (a == 2 && b == 0) {
puma[2][0] = 3;
}
if (a == 3 && b == 2) {
puma[3][2] = 3;
}
}
if (a == 3 && b == 2) {
puma[3][2] = 2;
for (a = 0; a < puma.length; a++) {
for (b = 0; b < puma[0].length; b++) {
System.out.print(puma[a][b] + " ");
}
System.out.print('\n');
}
System.out.println("Enter space for putting 3: ");
a = input.nextInt();
b = input.nextInt();
if (a == 1 && b == 2) {
puma[1][2] = 3;
}
if (a == 2 && b == 0) {
puma[2][0] = 3;
}
if (a == 2 && b == 1) {
puma[2][1] = 3;
}
}
}
if (a == 1 && b == 2) {
puma[1][2] = 1;
for (a = 0; a < puma.length; a++) {
for (b = 0; b < puma[0].length; b++) {
System.out.print(puma[a][b] + " ");
}
System.out.print('\n');
}
System.out.println("Enter space for putting 2: ");
a = input.nextInt();
b = input.nextInt();
}
if (a == 2 && b == 0) {
puma[2][0] = 1;
for (a = 0; a < puma.length; a++) {
for (b = 0; b < puma[0].length; b++) {
System.out.print(puma[a][b] + " ");
}
System.out.print('\n');
}
System.out.println("Enter space for putting 2: ");
a = input.nextInt();
b = input.nextInt();
}
if (a == 2 && b == 1) {
puma[2][1] = 1;
for (a = 0; a < puma.length; a++) {
for (b = 0; b < puma[0].length; b++) {
System.out.print(puma[a][b] + " ");
}
System.out.print('\n');
}
System.out.println("Enter space for putting 2: ");
a = input.nextInt();
b = input.nextInt();
}
if (a == 3 && b == 2) {
puma[3][2] = 1;
for (a = 0; a < puma.length; a++) {
for (b = 0; b < puma[0].length; b++) {
System.out.print(puma[a][b] + " ");
}
System.out.print('\n');
}
System.out.println("Enter space for putting 2: ");
a = input.nextInt();
b = input.nextInt();
}
for (int i = 0; i < puma.length; i++) {
for (int j = 0; j < puma[0].length; j++) {
System.out.print(puma[i][j] + " ");
}
System.out.print('\n');
}
}
}
}
//这是以后用looong试图以简短的方式做到的事情:(