2021-09-28

1. /**
 * 作业累加加和 求出 1-100之间的加和 求出 1-100之间的所有奇数和
 *
 */
public class Test_01 {
    public static void main(String[] args) {
        int sum = 0;
        for (int i = 1; i <= 100; i++) {
            sum += i;
            // System.out.println(i);
        }
        System.out.println(sum);

        int sum1 = 0;
        for (int i = 1; i <= 100; i += 2) {
            // if ( i % 2 == 1 ) {
            sum1 += i;
            // }
        }
        System.out.println(sum1);
    }
}

2.

需求:小芳的妈妈每天给她2.5元钱,她都会存起来,
 *
 * 但是, 每当这一天是存钱的第5天或者5的倍数的话,她都会花去6元钱,
 *
 * 请问,经过多少天,小芳才可以存到100元钱。
 *
 * @author 天亮教育-帅气多汁你泽哥
 * @Date 2021年9月28日 上午9:22:07
 */
public class Test_02 {
    public static void main(String[] args) {
        // 每天给的钱数
        double dayMoney = 2.5;
        // 存的钱数
        double moneySum = 0;
        // 已存的天数
        int dayCount = 1;

        while (moneySum < 100) {
            moneySum += dayMoney;
            if (dayCount % 5 == 0) {
                moneySum -= 6;
            }
            dayCount++;
        }
        // for ( ; moneySum < 100; dayCount++,moneySum+=dayMoney) {
        // if (dayCount % 5 == 0) {
        // moneySum-=6;
        // }
        // }
        // 因为最后是++之后再终止的,所以要-1
        System.out.println("第几天 : " + (dayCount - 1) + " 存够了 : " + moneySum);
    }
}


3.

我国最高山峰是珠穆朗玛峰:8848m,
 *
 * 我现在有一张足够大的纸张,厚度为:0.01m。
 *
 * 请问,我折叠多少次,就可以保证厚度不低于珠穆朗玛峰的高度?
 *
 * @author 天亮教育-帅气多汁你泽哥
 * @Date 2021年9月28日 上午9:34:32
 */
public class Test_03 {
    public static void main(String[] args) {
        // 统计次数
        int count = 0;
        // 转换为整数
        int start = 1;
        int end = 884800;
        while (start < end) {
            count++;
            start *= 2;
        }

        // for( ;start < end; ){
        // count++;
        // start*=2;
        // }

        System.out.println(count + "次之后,厚度为:" + start);
    }
}


4.

 有100匹马,分别是大马,中马,和小马 ,有100块砖头
 *
 * 大马 一次能驮3块砖 中马 一次能驮2块砖 三匹小马 一次能驮 1块砖
 *
 * 刚好一次驮完,问 有多少大马,多少中马,多少小马(每种马的个数不能为0,并且不能有闲着的马)
 *
 * 注意 : 小马个数 是3的倍数,类型可以使用double
 *
 * 设 各有 d,z,x 匹 d+z+x = 100; d*3 + 2*z + x/3 = 100;
 */
public class Test_04 {
    public static void main(String[] args) {
        int count = 0;
        for (double d = 1; d < 33; d++) {
            for (double z = 1; z < 50; z++) {
                // for (double x = 3; x < 97;x+=3) {
                count++;
                double x = 100 - d - z;
                if (d * 9 + 6 * z + x == 300) {
                    System.out.println("大马 : " + d + " , 中马 : " + z
                            + " , 小马 : " + x);
                }
                // }
            }
        }
        System.out.println(count);
    }
}


5.

 公鸡5块 , 母鸡 3块 , 小鸡 1块3只
 *
 * @author 天亮教育-帅气多汁你泽哥
 * @Date 2021年9月28日 下午2:04:08
 */
public class Test_05 {

    public static void main(String[] args) {
        for (int i = 0; i < 20; i++) {
            for (int j = 0; j < 33; j++) {
                double x = 100 - j - i;
                if (i*5+j*3+x/3 == 100) {
                    System.out.println(i+","+j+","+x);
                }
            }
        }
    }
}


6.

 1-10000 之间的完全数
 *
 * 因子之和等于该数
 *
 * 比如 6 : 1,2,3  
 *
 * @author 天亮教育-帅气多汁你泽哥
 * @Date 2021年9月28日 下午2:07:32
 */
public class Test_06 {

    public static void main(String[] args) {
        for (int i = 1; i <= 10000; i++) {
            // 记录和
            int sum = 0;
            for (int j = 1; j < i; j++) {
                if (i % j == 0) {
                    sum+=j;
                }
            }
            if (sum == i) {
                System.out.println(i);
            }
            // 重新赋值
            sum = 0;
        }
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值