java 作业 1到100之间的所有整数中出现多少个9(注意:问的是出现多少个9!) 作业 牛逼 水仙花数等等1~999999

作业 1到100之间的所有整数中出现多少个9(注意:问的是出现多少个9!)
/public static void main15(String[] args) {
int count=0;
for (int i = 1; i < 100; i++) {
if (i%109) {
count++; //回车加countine也可输出含有9 的有几个数
} //else if() 输出有几个数含有9
if (i/10
9) {
count++;
}
}
System.out.println(count);
}
/ //注意:找几进制的数字的每一位上是几 只需要除几 取模几就行

//作业 牛逼 水仙花数等等1~999999
/*public static void main16(String[] args) {
    for (int n = 0; n < 999999; n++) {
        int count = 0;//123
        int temp = n;
        while (temp != 0) {  //先判断是几位数
            count++;
            temp = temp / 10;
        }
        //count=3 n=123
        temp = n;
        int sum = 0;
        while (temp != 0) {
            sum += Math.pow(temp % 10, count);
            temp = temp / 10;
        }
        if (sum == n) {
            System.out.println(sum + " "+"is my result!");
        }
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值