In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to use java to achieve horse pedal board games, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
The details are as follows
There is such a game in 4399 Mini Game.
This is the code implementation.
Package com.HorseChess;import java.awt.*;import java.util.ArrayList;import java.util.Comparator;import java.util.Scanner;public class HorseChess {private static int X; private static int Y; private static boolean visited []; private static boolean finished; public static void main (String [] args) {Scanner sc = new Scanner (System.in); System.out.println ("Please enter a line:"); X = sc.nextInt () System.out.println ("Please enter column:"); Y = sc.nextInt (); System.out.println ("Please enter the row of the chess piece:"); int row = sc.nextInt (); System.out.println ("enter the column of the chess piece:"); int column = sc.nextInt (); int [] [] chessboard = new int [X] [Y] Visited = new boolean [Xeroy]; traverchess (chessboard,row-1,column-1,1); for (int [] rows: chessboard) {for (int step: rows) {System.out.print (step + "\ t");} System.out.println () }} public static void traverchess (int [] [] chessboard,int row,int column,int step) {chessboard [row] [column] = step; visited [row * X+column] = true; ArrayList ps = next (new Point (column,row)); sort (ps); while (! ps.isEmpty ()) {Point p = ps.remove (0) If (! visited [p.y*X+p.x]) {traverchess (chessboard,p.y,p.x,step+1);}} if (step=0&& (p1.y = curpoint.y-1) > = 0) {ps.add (new Point (p1)) } if ((p1.x = curpoint.x-1) > = zero & (p1.y = curpoint.y-2) > = 0) {ps.add (new Point (p1));} if ((p1.x = curpoint.x + 1))
< X && (p1.y = curpoint.y - 2)>= 0) {ps.add (new Point (p1));} if ((p1.x = curpoint.x + 2)
< X && (p1.y = curpoint.y - 1)>= 0) {ps.add (new Point (p1));} if ((p1.x = curpoint.x + 2)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.