Example13_6

来源:互联网 发布:商业计划书的优化答案 编辑:程序博客网 时间:2024/06/15 20:03
package cn.hanfeng.example13_6;


import java.util.Stack;


public class Example13_6 {
public static void main(String args[]){
      Stack <Integer>stack=new Stack<Integer>();
      stack.push(new Integer(1));
      stack.push(new Integer(1));
      int k=1;
      while(k<=10){
     for(int i=1;i<=2;i++){
     Integer F1=stack.pop();
     int f1=F1.intValue();
     Integer F2=stack.pop();
     int f2=F2.intValue();
     Integer temp=new Integer(f1+f2);
     System.out.println(""+temp.toString());
     stack.push(temp);
     stack.push(F2);
     k++;
     }
      }
}
}
原创粉丝点击