#include #include #include #include /** * 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. **/ typedef struct pair { int v1; int v2; } pair; int compare(const void* a, const void* b) { const pair* p1 = (const pair*)a; const pair* p2 = (const pair*)b; return p1->v2 > p2->v2; } int main() { const int maxM = 8; int index_highest_mountain = 0; int max_highest_mounter = 0; // game loop while (1) { for (int i = 0; i < maxM; i++) { // represents the height of one mountain. int mountain_h; scanf("%d", &mountain_h); if (max_highest_mounter < mountain_h) { max_highest_mounter = mountain_h; index_highest_mountain = i; } } printf("%d\n", index_highest_mountain); max_highest_mounter = 0; index_highest_mountain = 0; } return 0; }