You can convert to millivolts in the input function:
1 2 3 4 5 6
|
istream& operator>>(istream& is, Record& rec)
{
is >> rec.temperature >> rec.voltage >> rec.sensitivity;
rec.voltage *= 1000.0;
return is;
}
|
It's unclear what you mean by "sort through" and find the "corresponding value". But I can guess. :-) I assume the "corresponding value" you want is the sensitivity. Exactly how you would do that depends on the relationship between temperature and voltage.
From the given table it looks like:
(A) as the temperature increases the voltage decreases, and
(B) the input table is already sorted (by increasing temperature).
Are both A and B always the case?
If A is always true but B is not always true, it's easy enough to sort the table after reading it in. Then you can do a binary search on either the temperature (increasing) or voltage (decreasing) to find the corresponding sensitivity.
If A is not always true, then it's a little more difficult since if the table is sorted by temperature then it wouldn't be sorted (even in reverse order) for the voltage, and vice versa.