黑马程序员技术交流社区
标题:
跪求马马们都是怎么学习的呢??可不可以相互交流一下经验
[打印本页]
作者:
坏坏坏男孩
时间:
2016-7-8 22:26
标题:
跪求马马们都是怎么学习的呢??可不可以相互交流一下经验
今天晚自习老师除了一道拓展训练题,同班同学又做出来的,但是我却没有做出来,我们是一块进的班级,自我感觉平时课上课下挺努力的但还是感觉到感觉差距很大,,,,,求大神们传授一下学习经验,本人安卓零基础第九天...
老师出的编程题如下,顺便帮忙做一下,,
我有 100 元 , 买 100 只 鸡;
公鸡 5 元1只, 母鸡 3 元1只, 小鸡 1 元3只.
问有多少种组合.
作者:
seexp
时间:
2016-10-9 11:57
public static int print(int money) {
int nowMoney = 0;
int cock = 0;
int hen = 0;
int chick = 0;
int count = 0;
for (int i = 0; i <=money/5; i++) {
cock = i;
nowMoney = money-i*5;
if (nowMoney >0) {
for (int h = 0; h <=nowMoney/3; h++) {
hen = h;
nowMoney = nowMoney-h*3;
if (nowMoney >0) {
for (int j = 0; j <=nowMoney/1; j++) {
chick = j*3;
if (nowMoney-j*1 == 0) {
System.out.println("公鸡:"+cock+"只 母鸡:"+hen+"只 小鸡"+chick+"只 ");
count++;
}
}
}
}
}
}
return count;
}
作者:
seexp
时间:
2016-10-9 12:01
public static int print(int money) {
int nowMoney = 0;
int cock = 0;
int hen = 0;
int chick = 0;
int count = 0;
for (int i = 0; i <=money/5; i++) {
cock = i;
nowMoney = money-i*5;
if (nowMoney >0) {
for (int h = 0; h <=nowMoney/3; h++) {
hen = h;
nowMoney = nowMoney-h*3;
if (nowMoney >0) {
for (int j = 0; j <=nowMoney/1; j++) {
chick = j*3;
if (nowMoney-j*1 == 0) {
System.out.println("公鸡:"+cock+"只 母鸡:"+hen+"只 小鸡"+chick+"只 ");
count++;
}
}
}
}
}
}
return count;
}
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2