爷哭了,一道脑残题,就因为是英文题干,愣是给爷整懵了
服服服,我的锅
#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()
{
// game loop
while (1) {
int max_i = 0;
int max_h = 0;
for (int i = 0; i < 8; i++) {
// represents the height of one mountain.
int mountain_h;
scanf("%d", &mountain_h);
if (mountain_h >= max_h){
max_h = mountain_h;
max_i = i;
}
}
printf("%d\n", max_i);// Write an action using printf(). DON'T FORGET THE TRAILING \n
//fprintf(stderr, "Debug messages...\n");// To debug: fprintf(stderr, "Debug messages...\n");
// The index of the mountain to fire on.
}
return 0;
}
最佛的还是,我一直原来的输出代码是:
printf("%d", max_i);
就一直整不明白,我到底为什么没通过
然后百度了一波,看到一位C艹的哥们的代码
cout << imax <<endl
……
心 态 爆 炸
算了,就当是学英语了…希望未来能玩地越来越香叭……
QnQ