tasks and solutions with ++, programming practice

Tasks and Solutions: A pointer to a pointer

1) Create a two-dimensional array of 5x5, fill it with random numbers from 10 to 99 and display. Swap the maximum element of each row with the first element in the corresponding row. The problem solved by the pointer.

2) The challenge for the multiplication of matrices. The user arbitrarily sets the dimension of the two arrays and fills the values ​​manually. Do not forget, that it is necessary to allocate the appropriate memory locations for matrices, that the user will fill in for the final third of the matrix. Next, display on the screen, both the matrix and filled the resulting matrix (their play).

Maybe someone knows, how to multiply matrices. Watch this short video (author: Prihodovsky MA)

To support our site – click on the piggy bank and choose any convenient way.

Tasks and solution: A pointer to a C ++ pointer

8 thoughts on “Tasks and Solutions: A pointer to a pointer

  1. You are wrong to rid the memory of the second task, after a != c. When you enter the matrix 3×2 and 2×3 gives an error message.
    For the second array to do a separate cycle, and the first and the third may be one in.

  2. Decided Zadachu№1 using pointers in the search for the maximum value. Prokomentirujte please can you do that and how much it is validly?
    P.S.: sorri, I'm still just learning, so this question ))

  3. too awful?

  4. I sdelyal. :) The solution is different from yours, but the program should work correctly, several times I checked.

  5. Поправьте меня, но в конце решения второй задачи, где освобождается память, неверно учитываются размеры массивов, что ведет к ошибке, tk. кол-во рядов М2 (i в цикле) должно быть < with.

Leave a Reply

Place code in tags: <pre class="lang:c++ decode:true ">YOUR CODE</pre>