D
D
Denis Akhunov2020-12-03 17:35:28
C++ / C#
Denis Akhunov, 2020-12-03 17:35:28

Can you suggest how to do this (square matrix)?

Create and display a matrix of the form:
1 2 3 4 5
2 3 4 5 1
3 4 5 1 2
4 5 1 2 3
5 1 2 3 4

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ananiev, 2020-12-03
@denywho

int matrix[5][5] = {
    {1,2,3,4,5},
    {2,3,4,5,1},
    {3,4,5,1,2},
    {4,5,1,2,3},
    {5,1,2,3,4}
  };

  for (int i = 0; i < 5; i++)
  {
    for (int j = 0; j < 5; j++)
    {
      std::cout << matrix[i][j] << " ";
    }
    std::cout << std::endl;
  }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question