Skip to the task
Layout
Back to classic view

You are looking ahead. Your place is still task 1: Arrays.

EDITTask 9 of 28 · step 5: SortingSort a copy
Sort a copy in practice/04/

The function sort_array (selection sort), a copy sorted, printing it and the median.

Checklist

  • Every task is one commit with a clear message.
  • Zero compiler warnings: the code builds with -Werror.
  • Once per topic you step through your code in the debugger (CLion, gdb).
  • Every function has preconditions and postconditions, and assert tests check them.
Details & hint
  • The outer loop i from 0 to n - 2, the inner j looks for the smallest of the rest.
  • A swap through temp.
  • main: a copy with a loop, sort_array(sorted, DAYS), the median sorted[DAYS / 2].

Stuck? Sort the copy, not temperatures: the search has to return the day in the original order.

practice 04 CMakeLists.txt Code Diff
UNCHANGED This step does not change this file.
add_executable(p04_average main.c)
target_link_libraries(p04_average PRIVATE course_input)