-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDescent.cpp
More file actions
39 lines (32 loc) · 1.04 KB
/
Descent.cpp
File metadata and controls
39 lines (32 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
/**
* The while loop represents the game.
* Each iteration represents a turn of the game
* where you are given inputs (the heights of the mountains)
* and where you have to print an output (the index of the mountain to fire on)
* The inputs you are given are automatically updated according to your last actions.
**/
int main()
{
// game loop
while (1) {
int target_h = -1;
int target_ind = 0;
for (int i = 0; i < 8; i++) {
int mountain_h; // represents the height of one mountain.
cin >> mountain_h; cin.ignore();
if (mountain_h > target_h) {
target_h = mountain_h;
target_ind = i;
}
}
// Write an action using cout. DON'T FORGET THE "<< endl"
// To debug: cerr << "Debug messages..." << endl;
cout << target_ind << endl; // The index of the mountain to fire on.
}
}