Question: Please write in C++ 3. Given a data set with 1000 TemperatureReading objects, print out the object with the minimum temperature in the data set
Please write in C++
3. Given a data set with 1000 TemperatureReading objects, print out the object with the minimum temperature in the data set as well as the object with the maximum temperature in the data set. You may not use a raw loop to solve this problem.
Starter Code:
#include#include #include #include #include "TemperatureReading.h" template std::ostream& operator<<(std::ostream& out, std::vector & values) { out << "[ "; for (const auto& value : values) { out << "\t" << value << ", "; } out << "]"; return out; } int main() { std::vector data; for (auto i = 0; i < 1000; i++) { data.push_back(generateRandomTemperatureReading()); } // TODO: print out the min and max element in the list according to temperature }
Sample Output:
The minimum temperature was: Temp(id='89', city='San Francisco', value='0.0412063') The maximum temperature was: Temp(id='4', city='San Francisco', value='39.9422')
Step by Step Solution
There are 3 Steps involved in it
To solve this problem using C we need to utilize standard library functions that allow us to find the minimum and maximum temperatures without manuall... View full answer
Get step-by-step solutions from verified subject matter experts
