You have made a device that automatically measures both distance from a magnet and the magnetic field strength at that distance. The device sends the pair of data to your computer as a pair of real numbers. However, the device moves back and forth as it takes data, so neither the field measurement nor the distance measurement arrives in ascending or descending order. Write a code vector_sort that receives a two- dimensional array of numbers and sorts them based on either the first column or the second column (this must be an input to the function. The function must also either sort high-to-low or low-to-high, based on an input value. Write a main function that can read up to twenty pairs of data. The main function must also input whether you want to sort high-to-low or low-to high. It must also input whether you want to sort on magnetic field or distance. Finally the code must print the pair data as originally entered and then, after calling vector_sort, the ordered pair data. C Program
You have made a device that automatically measures both distance from a magnet and
the magnetic field strength at that distance. The device sends the pair of data to your
computer as a pair of real numbers. However, the device moves back and forth as it
takes data, so neither the field measurement nor the distance measurement arrives in
ascending or descending order. Write a code vector_sort that receives a two-
dimensional array of numbers and sorts them based on either the first column or the
second column (this must be an input to the function. The function must also either sort
high-to-low or low-to-high, based on an input value. Write a main function that can
read up to twenty pairs of data. The main function must also input whether you want to
sort high-to-low or low-to high. It must also input whether you want to sort on magnetic
field or distance. Finally the code must print the pair data as originally entered and then,
after calling vector_sort, the ordered pair data.
C Program
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images