Array Pointer Arithmetic Practice
*arr | **arr |
*(arr + row) | **(arr + column) |
Tarefa
Swipe to start coding
- Access the last element of the second row of the array.
- Access the fourth element of the third row of the array.
- Output the sum of these elements.
Solução
solution
99
1
2
3
4
5
6
7
8
9
10
11
12
13
#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?
Obrigado pelo seu feedback!
Seção 2. Capítulo 4
99
1
2
3
4
5
6
7
8
9
10
11
12
13
#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
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo