am intamplator problema rezolvata pe pbinfo de cativa ani,nu le am cu info,dar e verificata:)
#include<iostream>
using namespace std;
int main()
{
unsigned int n, k, matrice[21][21], p = 1;
cin >> n >> k;
for (int i = 1; i <= n; i++)
{
for (int j = 0; j < n; j++)
{
for (int kk = 1; kk <= k; kk++)
{
matrice[i][p] = j + i;
p = p + 1;
}
}
p = 1;
}
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= k * n; j++)
cout << matrice[i][j] << " ";
cout << "\n";
}
return 0;
}