This is a simple game I'm writing to test the idea of using games to teach C++.
https://learncodethehardway.com/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
550 B
33 lines
550 B
6 months ago
|
#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;
|
||
|
}
|