Kod:
public class Stackb {
public Node top = null;
public int size = 0;
public **** push(Node newNode){
newNode.link = top;
top = newNode;
size++;
}
public Node pop(){
Node temp = null;
if(top == null){
System.out.println("Yığıt Boş");
}
else{
temp = top;
top = top.link;
}
size--;
return temp;
}
public Node peek(){
if(top == null){
System.out.println("Yığıt Boş");
return top;
}
else
return top;
}
}
public class Node {
public Node link;
String ad,soyad;
int no;
public Node(){
this(0,null,null);
}
public Node(int no,String ad,String soyad){
this.no = no;
this.ad = ad;
this.soyad = soyad;
}
}
public class FinalExamEx {
public static **** main(String[] args) {
int dizi[] = {-25,10,12,-4,-9,88,54,-35,65,-8,-7,45,59,-2,74};
Stackb stc = new Stackb();
for (int i = 0; i < dizi.length; i++) {
if(dizi[i] < 0){
stc.push(new Node(dizi[i], null, null));
}
else
continue;
}
}
}