作业 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/109) {
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!");
}
}
}