国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

? Java Java???? ?? ???? BFS? ???? ?? ????? ?? ?? ??

?? ???? BFS? ???? ?? ????? ?? ?? ??

Nov 10, 2020 pm 03:38 PM
bfs java ?? ?? ?? ??

?? ???? BFS? ???? ?? ????? ?? ?? ??

? ??

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 ??? ????? ?? ?? ??? ?????!

? ????? ??
? ?? ??? ????? ???? ??? ??????, ???? ?????? ????. ? ???? ?? ???? ?? ??? ?? ????. ???? ??? ???? ???? ??? ?? admin@php.cn?? ?????.

? AI ??

Undresser.AI Undress

Undresser.AI Undress

???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover

AI Clothes Remover

???? ?? ???? ??? AI ?????.

Video Face Swap

Video Face Swap

??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

???

??? ??

???++7.3.1

???++7.3.1

???? ?? ?? ?? ???

SublimeText3 ??? ??

SublimeText3 ??? ??

??? ??, ???? ?? ????.

???? 13.0.1 ???

???? 13.0.1 ???

??? PHP ?? ?? ??

???? CS6

???? CS6

??? ? ?? ??

SublimeText3 Mac ??

SublimeText3 Mac ??

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

???

??? ??

??? ????
1601
29
PHP ????
1502
276
???
JDBC? Java? ??? ???? ??? ?????? JDBC? Java? ??? ???? ??? ?????? Aug 02, 2025 pm 12:29 PM

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

Java? ??? ?? ??? ?????? Java? ??? ?? ??? ?????? Aug 02, 2025 am 02:38 AM

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

Java ??? ?? ?? : Spring Boot vs Quarkus vs Micronaut Java ??? ?? ?? : Spring Boot vs Quarkus vs Micronaut Aug 04, 2025 pm 12:48 PM

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

???? ?? ? ??? ?? ???? ?? ? ??? ?? Aug 01, 2025 am 06:40 AM

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

??? ??? Java?? ??? ?????? ??? ??? Java?? ??? ?????? Aug 02, 2025 pm 01:55 PM

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

??? ???? html` ?? '??? ????? ??? ???? html` ?? '??? ????? Aug 03, 2025 am 11:07 AM

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

Java ?? ?? ?? : Maven vs. Gradle Java ?? ?? ?? : Maven vs. Gradle Aug 03, 2025 pm 01:36 PM

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

??? ????. ?? ??? ?? ??? ????. ?? ??? ?? Aug 02, 2025 am 06:26 AM

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

See all articles