/************************************************
 * CP-I warmup 1999-2000
 * Problem #5
 ***********************************************/

/*
 * Question:
 *
 * Taking a two-dimensional array (N x N) of integers as input to your 
 * program, display only the elements in the upper-tringle of the matrix.
 * The program should display the diagonal and the lower-triangle elements
 * of the matrix as X irrespective of its values.
 *
 * Example:     Input:
 *              2       3       4       5
 *              6       0       2       6
 *              9       8       -9      7
 *              8       -9      10      0
 *              Output:
 *              X       3       4       5
 *              X       X       2       6
 *              X       X       X       7
 *              X       X       X       X
 */

#include <stdio.h>
#define MAX_SIZE        10

main()
{
        int matrix[MAX_SIZE][MAX_SIZE]={0};
        int i,j,size;

        printf("Give the size of square matrix: ");
        scanf("%d",&size);

        if(size>MAX_SIZE)
                printf("This size is not supported. Try something less than %d\n",MAX_SIZE+1);
        
        for(i=0;i<size;i++)
                for(j=0;j<size;j++)
                        scanf("%d",&matrix[i][j]);
        printf("Output: \n");
        for(i=0;i<size;i++)
        {
                for(j=0;j<size;j++)
                        if(j>i)
                                printf("%-4d ",matrix[i][j]);
                        else
                                printf("X    ");
                printf("\n");
        }
}