题解 | #HJ072 百钱买百鸡问题#

百钱买百鸡问题

http://www.nowcoder.com/practice/74c493f094304ea2bda37d0dc40dc85b

import java.util.Scanner;

/**
 * HJ72 百钱买百鸡问题 - 简单
 */
public class HJ072 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            print(sc.nextInt());
        }
        sc.close();
    }

    private static void print(int num) {
        int x, y, z;
        for (x = 0; x <= 14; x++) {
            if ((100 - 7 * x) % 4 == 0) {
                y = (100 - 7 * x) / 4;
                z = 100 - x - y;
                System.out.print(x + " ");
                System.out.print(y + " ");
                System.out.print(z + " ");
                System.out.println();
            }
        }
    }
}
全部评论

相关推荐

04-16 19:19
已编辑
合肥大学 Java
刷了100道题的大老虎很想提桶:27届现在早没日常hc了,不可能找到的,等暑假9月吧
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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