package oj.test;
import java.util.*;
public class Demo4 {
/**
* @用Stack实现斐波那契数列的前十项
*/
public static void main(String[] args) {
Stack<Long> mystack = new Stack<Long>();
sop("斐波那契数列的前十项是:");
sop(" "+1);
sop(" "+1);
mystack.push(new Long(1));
mystack.push(new Long(1));
int k=1;
while(k<=8){
for(long i=0;i<2;i++){
Long F1 = (Long)mystack.pop();
Long F2 = (Long)mystack.pop();
long f1 = F1.longValue();
long f2 = F2.longValue();
sop(" "+(f1+f2));
//Long tmep = new Long(f1+f2);
mystack.push(new Long(f1+f2));
mystack.push(F2);
k++;
}
}
}
public static void sop(Object obj){
System.out.print(obj);
}
}