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

bookChallenge: Array Pointer Arithmetic Practice

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

Swipe to start coding

In real-world applications like weather stations, industrial sensors, or scientific experiments, data is often stored in a 2D grid, where each element represents a measurement.

In this task, you will implement a function that finds the maximum temperature using pointer-to-pointer syntax, which helps you understand how 2D arrays are stored in memory and how to navigate them with pointers.

  1. Declare a variable maxTemp to store the maximum temperature.
  2. Initialize maxTemp with the value of the first element of the array using pointer syntax.
  3. For each element, access it using pointer syntax: *(*(arr + i) + j).
  4. Compare the accessed element with maxTemp.
  5. If the element is greater than maxTemp, update maxTemp with this new value.
  6. After all elements are processed, return maxTemp as the maximum temperature found in the grid.

Solução

solution.cpp

solution.cpp

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 4
single

single

Pergunte à IA

expand

Pergunte à IA

ChatGPT

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

close

Awesome!

Completion rate improved to 5.88

bookChallenge: Array Pointer Arithmetic Practice

Deslize para mostrar o menu

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

Swipe to start coding

In real-world applications like weather stations, industrial sensors, or scientific experiments, data is often stored in a 2D grid, where each element represents a measurement.

In this task, you will implement a function that finds the maximum temperature using pointer-to-pointer syntax, which helps you understand how 2D arrays are stored in memory and how to navigate them with pointers.

  1. Declare a variable maxTemp to store the maximum temperature.
  2. Initialize maxTemp with the value of the first element of the array using pointer syntax.
  3. For each element, access it using pointer syntax: *(*(arr + i) + j).
  4. Compare the accessed element with maxTemp.
  5. If the element is greater than maxTemp, update maxTemp with this new value.
  6. After all elements are processed, return maxTemp as the maximum temperature found in the grid.

Solução

solution.cpp

solution.cpp

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 4
single

single

some-alt