⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 3806329_ac_157ms_1892k.java

📁 北大大牛代码 1240道题的原代码 超级权威
💻 JAVA
字号:
import java.util.*;
import java.io.*;

public class Main {
	private String[] board = new String[16];
	private Scanner in;

	public static void main(String[] args) {
		new Main().run();
	}

	private void run() {
		try {
			in = new Scanner(System.in);
			//in = new Scanner(new FileInputStream("g.in"));
		} catch (Exception e) {
			return ;
		}
		in.next();
		for (int i = 0; i < 16; i++) {
			board[i] = in.next();
		}
		String out = "White: ";
		String out2 = "Black: ";
		for (int i = 0; i < 16; i += 2) {
			for (int j = 2; j < 33; j += 4) {
				if (board[i].charAt(j) == 'K') {
					out += "K" + change(i / 2, (j - 2) / 4) + ",";
				}
				if (board[i].charAt(j) == 'k') {
					out2 += "K" + change(i / 2, (j - 2) / 4) + ",";
				}
			}
		}
		for (int i = 0; i < 16; i += 2) {
			for (int j = 2; j < 33; j += 4) {
				if (board[i].charAt(j) == 'Q') {
					out += "Q" + change(i / 2, (j - 2) / 4) + ",";
				}
				if (board[i].charAt(j) == 'q') {
					out2 += "Q" + change(i / 2, (j - 2) / 4) + ",";
				}
			}
		}
		for (int i = 0; i < 16; i += 2) {
			for (int j = 2; j < 33; j += 4) {
				if (board[i].charAt(j) == 'R') {
					out += "R" + change(i / 2, (j - 2) / 4) + ",";
				}
				if (board[i].charAt(j) == 'r') {
					out2 += "R" + change(i / 2, (j - 2) / 4) + ",";
				}
			}
		}
		for (int i = 0; i < 16; i += 2) {
			for (int j = 2; j < 33; j += 4) {
				if (board[i].charAt(j) == 'B') {
					out += "B" + change(i / 2, (j - 2) / 4) + ",";
				}
				if (board[i].charAt(j) == 'b') {
					out2 += "B" + change(i / 2, (j - 2) / 4) + ",";
				}
			}
		}
		for (int i = 0; i < 16; i += 2) {
			for (int j = 2; j < 33; j += 4) {
				if (board[i].charAt(j) == 'N') {
					out += "N" + change(i / 2, (j - 2) / 4) + ",";
				}
				if (board[i].charAt(j) == 'n') {
					out2 += "N" + change(i / 2, (j - 2) / 4) + ",";
				}
			}
		}
		for (int i = 14; i >= 0; i -= 2) {
			for (int j = 2; j < 33; j += 4) {
				if (board[i].charAt(j) == 'P') {
					out += change(i / 2, (j - 2) / 4) + ",";
				}
			}
		}
		for (int i = 0; i < 15; i += 2) {
			for (int j = 2; j < 33; j += 4) {
				if (board[i].charAt(j) == 'p') {
					out2 += change(i / 2, (j - 2) / 4) + ",";
				}
			}
		}
		out = out.substring(0, out.length() - 1);
		System.out.println(out);
		out2 = out2.substring(0, out2.length() - 1);
		System.out.println(out2);
	}

	private String change(int row, int col) {
		return "" + ((char)('a' + col)) + Integer.toString(8 - row);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -