import java.util.*;
public class Pyramid
{
ArrayList <Integer> Pline = new ArrayList<Integer>();
ArrayList <Integer> Cline = new ArrayList<Integer>();
public Pyramid()
{
//previous line array, current line array. use previous line to determine current line then set previous line to current line and loop it again
int lines = 5;
Pline.add(2);
/*
2
*/
System.out.println(Pline);
Pline = new ArrayList<Integer>();
Pline.add(2);
Pline.add(2);
System.out.println(Pline);
while (lines>0){
/*
coding in here that determines the lines
*/
Cline = new ArrayList<Integer>();
Cline.add(2);
for(int i = 0; i<Pline.size()-1; i++){
Cline.add(Pline.get(i)*Pline.get(i+1));
}
Cline.add(2);
System.out.println(Pline) ;
Pline = new ArrayList<Integer>();
// Pline = Cline;
for(int j=0; j<Cline.size(); j++){
Pline.add(Cline.get(j));
}
lines--;
}
}
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.