I'm doing a project where I have to store information gathered (temperature and the time it was taken in seconds) in two seperate vectors. After an unknown amount of data has been enterd, and the end-of-file has been reached, I have to display the highest temperature and the time(s) it occured (bear in mind that the highest temperature may be recorded more than once). The output of that part should be as follows:
Highest temperature: 51
Recorded at time(s):
Something like that. The time should also be converted to hours and minutes. To the point: I've done some research on bubble sorting, but they only use it for arrays. I'd like to know if anyone can help me gain some insight on using bubble sort in this scenario. I've been struggling with this for quite some time now.
I'm doing a project where I have to store information gathered (temperature and the time it was taken in seconds) in two seperate vectors.
Why two separate vectors? What if you had 10 other pieces of data concerning the weather? Create 12 vectors?
// any other information concerning the weather for that particular
Then you create an array or vector of the struct. The struct contains all the information needed for one weather item. Then you sort on the temperature field -- all other fields will follow along for the ride when/if you swap items in the sort.
To the point: I've done some research on bubble sorting, but they only use it for arrays.
A vector and array syntax is virtually the same using .
Thank you very much for the help. Your suggestion seems much easier and more efficient, sadly the project specifies that I should make use of two vectors, one containing all the recorded temperatures and the other their corresponding times. So there's no way around using two vectors. Any suggestions on how I can accomplish this?