-
Notifications
You must be signed in to change notification settings - Fork 0
/
yigin.java
49 lines (48 loc) · 943 Bytes
/
yigin.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package yiginuyglama;
class Eleman{
int icerik;
Eleman ileri;
public Eleman(int icerik){
this.icerik=icerik;
this.ileri=null;
}
}
public class yigin {
Eleman ust;
public yigin(){
ust=null;
}
boolean bosmu(){
if(ust==null) return true;
else return false;
}
void Ekle(Eleman yeni){
yeni.ileri=ust;
ust=yeni;
}
Eleman sil(){
Eleman e=ust;
if(!bosmu())
ust=ust.ileri;
return e;
}
int enBuyuk(){
int buyuk;
Eleman e;
yigin y1=new yigin();
e=sil();
y1.Ekle(e);
buyuk=e.icerik;
while(!bosmu()){
e=sil();
y1.Ekle(e);
if(e.icerik>buyuk)
buyuk=e.icerik;
}
while(!y1.bosmu()){
e=y1.sil();
Ekle(e);
}
return buyuk;
}
}