-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththe_descent.c
More file actions
46 lines (37 loc) · 1.07 KB
/
the_descent.c
File metadata and controls
46 lines (37 loc) · 1.07 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
40
41
42
43
44
45
46
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
/**
* 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()
{
struct mountain{
int h;
int n;
};
struct mountain mntn;
mntn.h=0; mntn.n=0;
// game loop
while (1) {
for (int i = 0; i < 8; i++) {
// represents the height of one mountain.
int temp;
scanf("%d", &temp);
if (temp>mntn.h){
mntn.h=temp;
mntn.n=i;
}
}
printf("%d\n", mntn.n); // The index of the mountain to fire on.
mntn.h=0;
// Write an action using printf(). DON'T FORGET THE TRAILING \n
// To debug: fprintf(stderr, "Debug messages...\n");
}
return 0;
}