Monday, October 30, 2006

Gain of the day :
1. Saw a complete Rainbow.
2. Saw a shooting star.
3. Realised that i can hold breath for 1 min.
4. Setup white light in my room.

Sunday, October 08, 2006

Pascal's Traingle w/o formula.

public static void PascalTriangle(int lines){

int [][] triangle ;
triangle= new int [lines][lines];
for (int lineIndex = 0 ; lineIndex < lines ; lineIndex++){

for (int col = 0 ; col < lineIndex ; col++) {
if ( (col == 0) || (col == lineIndex - 1 ) ) {
// First and last element in Pascal's triangle is always 1.
triangle[lineIndex][col] = 1 ;
} else {
if (lineIndex != 0 ) triangle[lineIndex][col] = triangle[lineIndex-1][col-1] + triangle[lineIndex-1][col];
}
System.out.print(" " + triangle[lineIndex][col] );
}
System.out.println();

}
}