島嶼數量問題(深度優先)

上個文章寫了廣度優先的解決方案,實際上用堆棧的方法也能解決code 遞歸自己就是一種系統堆棧,經過每次遞歸到系統堆棧爲0得到一個島嶼的土地遍歷。直接上代碼。遞歸 D_land.h #pragma once bool expand(int x, int y); typedef struct position { int x; int y; }pos; D_land.cpp #include<s
相關文章
相關標籤/搜索