Java realizes

xiaoxiao2021-03-06  19

The interface is very simple, the key is to reserve a row (column) plaid up and down.

Each time initialization and each of the pairs, you must automatically find a pair of pictures that can be eliminated, otherwise it will automatically sell the situation. This is the right thing to do when using a bomb.

The algorithm for finding the path between the two specified points is more complicated. The basic order is not turned, turn once, turn twice. The first two are relatively simple, the last one is about four cases, and the path is found separately. Simply talk about the algorithm found down:

Set the starting coordinates (SX, SY), endpoint coordinates (EX, EY);

1. First, the path to the originally stored is cleared; Decision (SX, SY 1) is a path (no picture), if there is a picture, this road is not connected, the algorithm ends. 3. Add (SX, SY 1) to the path; 4. If (EX, SY 1) is a passage (SX, SY 1) to (EX, SY 1) is a passage (EX, SY 1) to (EX) is path 5. The path is found, the algorithm ends. 6. Otherwise, SY returns the second step.

In fact, there is a faster way, but it is troublesome. The method is to look for four points: (SX, SYMAX): From the starting point, you can reach the farthest point (SX, SYMIN): From the starting point, you can achieve the farthest point (EX, EYMAX): from At the end, you can achieve the farthest point (EX, EYMIN): from the end point, you can reach the longest point, then find the common part of Symin-> Symax and Eymin-> Symax, if the public part exists, and There is Y the Y is in the common portion, and (SX, Y) to (EX, Y) is the path, and the path is found. Otherwise, there is no passage up and down.

I implemented the first algorithm with Java, the interface as shown above.

Copyright Notice: All pictures are found from the web, I don't have copyright. This software allows unlimited copy, distribution, communication, premise to ensure that the software code and the integrity and authenticity of all files are limited to research learning. I am not responsible for all losses caused by copies that use non-person directly distributed.

Note: The source code can be obtained in my resource download. Please download your friends yourself.

http://download.9cbs.net/user/nicholas_lin

转载请注明原文地址:https://www.9cbs.com/read-47299.html

New Post(0)