/* 
 * File:   pascal-triangle.cpp
 * Author: Muhammad Faruq Nuruddinsyah
 *
 * Created on May 3, 2013, 7:29 AM
 */

#include <iostream>

using namespace std;
#define N 5

int main(){
    // Create the triangle
    
    const int row = N;
    const int col = N * 2 - 1;
    int triangle[row][col];
    
    for(int i = 0; i < row; i++)
        for(int j = 0; j < col; j++)
            triangle[i][j] = 0;
    
    triangle[0][N - 1] = 1;
    triangle[row - 1][0] = 1;
    triangle[row - 1][col - 1] = 1;
    
    for(int i = 1; i < row; i++){
        for(int j = 1; j < col - 1; j++){
            triangle[i][j] = triangle[i - 1][j - 1] + triangle[i - 1][j + 1];
        }
    }
    
    
    // Print out the result
    
    for(int i = 0; i < row; i++){
        for(int j = 0; j < col; j++){
            if(triangle[i][j] != 0){
                cout << triangle[i][j] << " ";
            }else{
                cout << "  ";
            }
        }
        
        cout << endl;
    }
    
    return 0;
}