? ??
static Queue r = new LinkedList(); //創(chuàng)建隊(duì)列
(??? ?? ??: java ??)
?? ?? ??
r.offer(); ???? ??
r.peek(); ? ??? ??
?? ??:
?? ?? ??
package Two; import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class BFS { static int a[][] = new int [100][100]; //輸入迷宮 static int v[][] = new int [100][100]; //走過(guò)的標(biāo)記為1 static int startx,starty; //輸入起點(diǎn)位置 static int p,q; //輸入要到達(dá)的坐標(biāo)位置 static int dx[] = {0,1,0,-1}; //方向數(shù)組 static int dy[] = {1,0,-1,0}; static Queue<point> r = new LinkedList<point>(); //創(chuàng)建隊(duì)列 static class point{ //建立類(lèi)坐標(biāo)屬性 int x; int y; int step; }
??? ?? ??, ?? ?? ??
public static void main(String[] args) { Scanner in = new Scanner(System.in); int m = in.nextInt(); int n = in .nextInt(); for(int i=1;i<=m;i++) //輸入迷宮 for(int j=1;j<=n;j++) a[i][j] = in.nextInt(); startx = in.nextInt(); starty = in.nextInt(); //輸入目標(biāo)和起始位置 p = in.nextInt(); q = in.nextInt();
BFS ???? ??
1. ? ??
//BFS point start = new point(); //定義一個(gè)初始類(lèi)作為隊(duì)首 start.x = startx; start.y = starty; start.step = 0; r.offer(start); v[startx][starty]=1;
2. ??? ?????
while(!r.isEmpty()) { //當(dāng)隊(duì)列為空時(shí)跳出循環(huán) int x = r.peek().x; //把隊(duì)首的屬性賦值 int y = r.peek().y; int step = r.peek().step; if(x==p && y==q) { //到達(dá)目的地,退出循環(huán) System.out.println(step); break; } for(int i=0;i<4;i++) { //廣度遍歷,右下左上分別入隊(duì) int tx= x+dx[i]; int ty= y+dy[i]; if(a[tx][ty] == 1 && v[tx][ty]==0) { //判斷是否可以入隊(duì) //入隊(duì) point temp = new point(); //建立一個(gè)臨時(shí)類(lèi) temp.x = tx; temp.y = ty; temp.step = r.peek().step +1; r.offer(temp); //入隊(duì) v[tx][ty]=1; //標(biāo)記為1 } } r.poll(); //拓展完了需要隊(duì)首出隊(duì) } } }
?? ?? ??:
Java ????? ??? ?? ???? BFS? ???? ?? ????? ?? ?? ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

JDBC ????? ???? ????? ?? ?? ?? ??? ?? ?? ??? ?? ? ?? ??? ?? ?? ?? ??? ???????. 1. ????? ????? Conn.SetAutoCommit (False)?? ??????. 2. ??? ? ????? ?? ?? SQL ??? ?????. 3. ?? ??? ??? ?? Conn.commit ()?? ???? ??? ???? ???? ?? ??? ???? Conn.Rollback ()?? ??????. ???, ? ??? ???? ????, ??? ???? ????, ?? ??? ??? ?? ??? ??? ???? ? ???????. ?? ?? ?? ???? ????? ??? ???? ?? ?? ???? ???? ??? ????? ?? ??? ??? ? ?? ???? ?? ????.

?? ?? ? ?? ???? ???? ?? Java.Time ???? ???? ??????. 2. LocalDate, LocalDateTime ? LocalTime? ?? ?? ??? ??? ?????. 3. () ???? ???? ?? ??? ??? ????. 4. ???/???? ??? ???? ??? ????? ??? ??????. 5. ZonedDateTime ? Zoneid? ???? ???? ??????. 6. DateTimeFormatter? ?? ?? ? ?? ?? ?? ???; 7. ??? ?? ?? ?? ??? ????? ?? ??????. ?? Java? ?? ??? ???? ??? ??? ???? Java.Timeapi ??? ?? ??? ???????.

Pre-FormancetArtUptimeMoryUsage, Quarkusandmicronautleadduetocompile-timeprocessingandgraalvsupport, withquarkusoftenperforminglightbetterine serverless sinarios.2.thyvelopecosyste,

NetworkPortSandfirewallsworkTogetToenableCommunication whileensuringsecurity.1.networkportSarevirtualendpointsnumbered0–65535, Withwell-nownports like80 (http), 443 (https), 22 (ssh) ? 25 (smtp) ?? (specservices

Java 's Garbage Collection (GC)? ???? ???? ???? ??????, ?? ? ??? ??? ? ??? ??? ??? ??? ????. 1.GC? ?? ?? (? : ?? ??, ?? ???, ?? ?? ?)?? ??? ???? ????, ?? ? ??? ??? ???? ?????. 2. ?? ???? ????? ????, ?? ?? ??? ??? ???? ?? ??? ??????. 3. ?? ?? ?? ?? : ??? ?? (Eden, S0, S1)? ?? ????? ?????. ??? ??? ?? ? MajorGC? ???? ? ??? ? ????. Metaspace? ??? ?? ???? ?????. 4. JVM? ??? GC ??? ?????. SerialGC? ??? ?? ????? ?????. ParallelGC? ???? ??????. CMS? ?? ???

??? htmlinput ??? ???? ??? ???? ????? ??? ??? ?? ??? ???? ???? ? ????. 1. ???, ???, ??, ?? ? ??? ?? ??? ??? ?? ?? ?? ??? ???? ???? ??? ? ???? ??? ? ????. 2. HTML5? ?????? ??? ? ?? ?? ??? ?? ? ??? URL, ??, ?? ? ??? ?? ??? ??? ??????. 3. ?? ?? ? ? ??? ??? ???? ?? ??? ???? ???? ?? ???? ?? ???? ???? ?? ? ? ??? ?? ???????.

GradleisBetTerChoiceFormostNewProjectSduetoitssuperiorflexible, Performance, and ModernToolingsupport.1.Gradle'Sgroovy/kotlindslismoreConcisENDEXPRESSIVETHANMAVEN'SVOSEXML.2.GradleOutsMaveninbuildweedweedweedweedweedweedweedweedweedweedweedweedweedweede

DEFER? ??? ???? ?? ??? ??? ???? ? ?????. ?? ??? ?? ? ? ?? ????, ??? ??? ? ?? ?? (LIFO)? ??? ?????. 1. ?? ??? ??? ? ??? ?????. 2. ?? ??? ?? ??? ??? ????? ?????. 3. ?? ? ?? ?? ??? ? ????. 4. ??? ?????? ??? ??? ???? ?????. 5. ?? ??? ???? ?? ??? ?? ??? ?????. ??? ??? ?? ?? ? ???? ???? ? ????.
