Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Array Pointer Arithmetic Practice | Pointer Arithmetic
C++ Pointers and References

book
Array Pointer Arithmetic Practice

Access the row
Access the column
*arr
**arr
*(arr + row)
**(arr + column)
Tarea

Swipe to start coding

  1. Access the last element of the second row of the array.
  2. Access the fourth element of the third row of the array.
  3. Output the sum of these elements.

Solución

cpp

solution

#include <iostream>

int main()
{
int row = 5, col = 5;
float arr[row][col] { {2.7, 5.1, 9.9, 5.5, 7.2 },
{4.4, 1.0, 2.5, 9.3, 1.1 },
{8.5, 5.1, 5.2, 9.6, 4.3 },
{0.5, 4.8, 0.9, 6.0, 3.7 },
{8.3, 3.0, 0.3, 7.4, 6.6 } };
std::cout << (*(*(arr + 1) + 4)) + (*(*(arr + 2) + 3));
}

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 4
#include <iostream>

int main()
{
int row = 5, col = 5;
float arr[row][col] { {2.7, 5.1, 9.9, 5.5, 7.2 },
{4.4, 1.0, 2.5, 9.3, 1.1 },
{8.5, 5.1, 5.2, 9.6, 4.3 },
{0.5, 4.8, 0.9, 6.0, 3.7 },
{8.3, 3.0, 0.3, 7.4, 6.6 } };
std::cout << (_(_(arr + _) + _)) + (*(*(arr + _) + _));
}

Pregunte a AI

expand
ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

some-alt