首页 > 代码库 > 班上一个哥们java脑残的笔试题1,2,3,4等于12可以重复3分钟答出来

班上一个哥们java脑残的笔试题1,2,3,4等于12可以重复3分钟答出来

package com.hao947;

public class hao947 {

	public static void main(String[] args) {
		int a = 1;
		int b = 2;
		int c = 3;
		int d = 4;
		int count = 0;
		for (int i = 0; i <= 12; i++) {
			for (int j = 0; j <= 6; j++) {
				for (int k = 0; k <= 4; k++) {
					for (int l = 0; l <= 3; l++) {
						int sum = (a * i + b * j + c * k + d * l);
						if (sum == 12) {
							count++;
						}
					}
				}
			}
		}
		System.out.println(count);
	}
}