华为OD机试E卷-出租车计费(100分) JAVA

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int[] nums = Arrays.stream(in.nextLine().split("")).mapToInt(Integer::parseInt).toArray();
        System.out.println(calculate_price(nums));
    }

    private static int calculate_price(int[] nums) {
        int actual = 0;
        for (int num : nums) {
            actual = actual * 9 + num;
            if (num > 4) {
                actual -= 1;
            }
        }
        return actual;
    }

全部评论

相关推荐

野猪不是猪🐗:我assume that你must技术aspect是solid的,temperament也挺good的,however面试不太serious,generally会feel style上不够sharp
点赞 评论 收藏
分享
牛客ID:561366855:期望薪资多少?难以相信这简历找不到工作。说明二本电子信息专业想对口就业非常难。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务