I'm having a bit of trouble finding a way to bypass the infinite input loop I've put myself in. Here's the code:
int main()
{
vector<double>v;
double input;
double low = numeric_limits<double>::max();
double high = numeric_limits<double>::min();
cout << "Enter doubles in a sequence. << '\n';
while (cin >> input) {
v.push_back(input);
if (input < low) {
low = input;
cout << low << "is the new low" << '\n';
}
if (input > high) {
high = input;
cout << high << "is the new high" << '\n';
}
sort(v.begin(), v.end());
for (int i = 0; i < v.size(); ++i) {
cout << v[i] << " ";
}
cout << '\n';
}
cout << "Test";
}
The last output was just me attempting to test whether it would relay the "Test" back to me after attempting to use break/continue. The code I wrote was just used to make a note of the all the numbers a person would input and then update whether it was the lowest or the highest number and sort it into a vector. I wanted the program to bypass showing all the work by putting the all the string outputs after the while loop so that it wouldn't update in real time whenever a higher number or lower number would be entered.
For clarity issues, say you entered 2.6, 3.5, 6, 1.2, 9.2. It would constantly update that 2.6 is the highest so far, then 3.5, then 6, etc. I'd like for that process to be skipped and for the program to just show, at the end, 9.2 is the highest number and 1.2 is the lowest. Thank you for any assistance you can give me.