Codingame The descend_C语言版答案

爷哭了,一道脑残题,就因为是英文题干,愣是给爷整懵了
服服服,我的锅

#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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值