//cd c:\JavaTry2005\Pascal //javac Pascal100.java -Xlint:unchecked //java Pascal100 import java.util.*; import listp.*; public class Pascal100 { static ListP lt = new ListP(); //List処理への参照変数、static要 public static void main(String[] args) { final int NMAX = 15; // ListP lt = new ListP(in,alt2); ArrayList alt = new ArrayList(); alt.add(0,new Integer(1)); //第1項 [1] for (int i = 0; i < NMAX; i++) { System.out.println("alt=" + alt); ArrayList alt1=(ArrayList)alt.clone(); //clone()使用 ArrayList alt2=(ArrayList)alt.clone(); alt1 = lt.fput(new Integer(0),alt1); alt2 = lt.lput(new Integer(0),alt2); alt=pascal20(alt1,alt2); } } public static ArrayList pascal20(ArrayList nl1,ArrayList nl2) { if (nl1.isEmpty()) return nl1; Integer n1=(Integer)nl1.get(0); Integer n2=(Integer)nl2.get(0); int f=n1.intValue()+ n2.intValue(); /* Integer ff=new Integer(f); ListP lf = new ListP(ff,nl1); ListP lt1 = new ListP(nl1); return lf.fput (new Integer(f),pascal20(lt1.bf(nl1),lt1.bf(nl2))); */ return lt.fput (new Integer(f),pascal20(lt.bf(nl1),lt.bf(nl2))); } } /* C:\JavaTry2005\Pascal>javac Pascal100.java -Xlint:unchecked Pascal100.java:15: 警告: [unchecked] raw 型 java.util.ArrayList のメンバとしての add(int,E) への無検査呼び出しです。 alt.add(0,new Integer(1)); //第1項 [1] ^ 警告 1 個 C:\JavaTry2005\Pascal>java Pascal100 alt=[1] alt=[1, 1] alt=[1, 2, 1] alt=[1, 3, 3, 1] alt=[1, 4, 6, 4, 1] alt=[1, 5, 10, 10, 5, 1] alt=[1, 6, 15, 20, 15, 6, 1] alt=[1, 7, 21, 35, 35, 21, 7, 1] alt=[1, 8, 28, 56, 70, 56, 28, 8, 1] alt=[1, 9, 36, 84, 126, 126, 84, 36, 9, 1] alt=[1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1] alt=[1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1] alt=[1, 12, 66, 220, 495, 792, 924, 792, 495, 220, 66, 12, 1] alt=[1, 13, 78, 286, 715, 1287, 1716, 1716, 1287, 715, 286, 78, 13, 1] alt=[1, 14, 91, 364, 1001, 2002, 3003, 3432, 3003, 2002, 1001, 364, 91, 14, 1]C:*/