Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda 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)
Tarefa

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.

Solução

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));
}

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 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 + _) + _));
}

Pergunte à IA

expand
ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

We use cookies to make your experience better!
some-alt