public class Test2 {
public static void main(String[] args) {
int count = 0;
for (int wuYuan = 1; wuYuan < 10; wuYuan++) {
for (int liangYuan = 1; liangYuan < 25; liangYuan++) {
for (int yiYuan = 1; yiYuan < 50; yiYuan++) {
if (yiYuan*1 + liangYuan*2 + wuYuan*5 == 50)
System.out.println("一元:" + yiYuan + " 两元:" + liangYuan + " 五元:" + wuYuan);
count++;
}
}
}
System.out.println("共有" + count + "种换法");
}
}
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |