Computer Science на языке Java 2022 Дэвид Копец Классические задачи Computer Science на языке Java 2022 ббк


public int  hashCode() { final int



Download 6,2 Mb.
Pdf ko'rish
bet66/236
Sana25.02.2022
Hajmi6,2 Mb.
#464393
1   ...   62   63   64   65   66   67   68   69   ...   236
Bog'liq
Kopec Klassicheskie zadachi Computer Science na yazyke Java 643091

public int 
hashCode() {
final int 
prime = 31;
int 
result = 1;
result = prime * result + (boat ? 1231 : 1237);
result = prime * result + ec; 
result = prime * result + em;
result = prime * result + wc;
result = prime * result + wm;
return 
result;
}
// автоматическое создание Eclipse
@Override
public boolean 
equals(Object obj) {
if 
(
this 
== obj) {
return true
;
}
if 
(obj == 
null
) {
return false
;
}
if 
(getClass() != obj.getClass()) {
return false
;
}
MCState other = (MCState) obj;
if 
(boat != other.boat) {
return false
;
}
if 
(ec != other.ec) {
return false
;
}
if 
(em != other.em) {
return false
;


82
Глава 2.
Задачи поиска
}
if 
(wc != other.wc) {
return false
;
}
if 
(wm != other.wm) {
return false
;
}
return true
;
}
public static void 
main(String[] args) {
MCState start = 
new 
MCState(
MAX_NUM

MAX_NUM

true
);
Node solution =
GenericSearch.
bfs
(start, MCState::goalTest, MCState::
successors
);
if 
(solution == 
null
) {
System.
out
.println("No solution found!");

else 
{
List path = GenericSearch.
nodeToPath
(solution);
displaySolution
(path);
}
}
}
Приятно.видеть,.насколько.гибкими.могут.быть.параметризованные.функции.
поиска..Их.можно.легко.адаптировать.для.решения.разнообразных.задач..Вы.
должны.увидеть.что-то.вроде.следующего.(сокращенного).списка:
On the west bank there are 3 missionaries and 3 cannibals.
On the east bank there are 0 missionaries and 0 cannibals.
The boast is on the west bank.
0 missionaries and 2 cannibals moved from the west bank to the east bank.
On the west bank there are 3 missionaries and 1 cannibals.
On the east bank there are 0 missionaries and 2 cannibals.
The boast is on the east bank.
0 missionaries and 1 cannibals moved from the east bank to the west bank.

On the west bank there are 0 missionaries and 0 cannibals.
On the east bank there are 3 missionaries and 3 cannibals.
The boast is on the east bank.

Download 6,2 Mb.

Do'stlaringiz bilan baham:
1   ...   62   63   64   65   66   67   68   69   ...   236




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish