#include <iostream>
int main(void){
const int N = 3;
const int M = 5;
int mat[N][M];
int i, j, row = 0, col = 0, n = 1;
while(row <= (N - 1)){
i = row;
j = col;
while((i < N) && (j >= 0))
mat[i++][j--] = n++;
if(col < (M - 1))
++col;
else
++row;
}
for(i = 0; i < N; ++i){
for(j = 0; j < M; ++j){
std::cout.width(3);
std::cout << mat[i][j];
}
std::cout << std::endl;
}
return 0;
}
Объяснение: