simple-cpp-game-study/PPP3/ex04.cpp
2024-05-01 20:26:41 -04:00

32 lines
550 B
C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
vector<int> v = {5, 7, 9, 4, 6, 8};
for(unsigned int i = 0; i < v.size(); i++) {
cout << "i=" << v[i] << "\n";
}
vector<double> temps;
double temp;
do {
cin >> temp;
temps.push_back(temp);
} while(temp != 0);
for(int x : temps) {
cout << "TEMP " << x << "\n";
}
ranges::sort(temps);
cout << "Median is" << temps[temps.size() / 2] << "\n";
// try a runtime error
cout << "BANG" << temps[1000];
return 0;
}