資源簡(jiǎn)介
很不錯(cuò)的算法,可以用于尋路求解,用java實(shí)現(xiàn),eight為類(lèi),另一個(gè)為主方法
代碼片段和文件信息
/*
?*?To?change?this?template?choose?Tools?|?Templates
?*?and?open?the?template?in?the?editor.
?*/
package?javaapplication3;
/**
?*
?*?@author?Owner
?*/
//算法實(shí)現(xiàn)類(lèi)
public?class?asearch?{
????static?int?dest[][]?=?{{1?2?3}?{8?0?4}?{7?6?5}};
//312650784
????static?void?swap(eight?ee?int?i?int?j?int?m?int?n)?{
????????int?temp;
????????temp?=?ee.e[i][j];
????????ee.e[i][j]?=?ee.e[m][n];
????????ee.e[m][n]?=?temp;
????}
????static?int?compare(eight?a)?{
????????int?h?=?0?i?j;
????????for?(i?=?0;?i?3;?i++)?{
????????????for?(j?=?0;?j?3;?j++)?{
????????????????if?(a.e[i][j]?!=?dest[i][j])?{
????????????????????h++;
????????????????}
????????????}
????????}
????????return?h;
????}
//生成子狀態(tài)
????static?queue?born(eight?e)?{
????????int?m?=?1?n?=?1?i?=?0?j?=?0;
????????boolean?
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????文件???????2724??2011-05-30?10:27??eight.java
?????文件???????5307??2011-05-30?09:27??asearch.java
-----------?---------??----------?-----??----
?????????????????8031????????????????????2
評(píng)論
共有 條評(píng)論