[description of the problem]
The snake matrix is a triangular matrix on the basis of natural numbers starting from 1.
[input] there are multiple sets of data in the topic, and each group consists of a positive integer N. (N not more than 100)
Output for each set of data, output a snake line of N row. No extra space between the two sets of output. The number of the same row in the matrix triangle is separated by a space. Do not have extra space at the end of the line.
[input case] 5
[output example] 1361015259144 81371211
solved:
#include<stdio.h>
#define M 100
void main()
{
int N,i,j,a[M][M];
while(scanf("%d",&N)!='/0')
{
a[0][0]=1;
printf("%d",a[0][0]);
for(i=0;i<N-1;i++)
{
a[i+1][0]=a[i][0]+i+1;
for(j=0;j<N-i-1;j++)
{
a[i][j+1]=a[i][j]+j+i+2;
printf(" %d",a[i][j+1]);
}
printf("\n");
printf("%d",a[i+1][0]);
}
}
printf("\n");
}