Square Problem in c++

1 2 3 4 5
2 2 3 4 5
3 3 3 4 5
4 4 4 4 5
5 5 5 5 5

How I am solve it?
I am done algorithm but code is not correct.