class Demo4 {
public static void main(String[] args) {
double h =0.001;
int count =0;
for (;h<=8848 ;h*=2 ) {
count++;
}
System.out.println(count);
}
}
while 循环
class Demo4 {
public static void main(String[] args) {
double h =0.001;
int count =0;
while(h<=8848){
h*=2;
count++;
}
System.out.println(count);
}
}
do while 循环;
class Demo4 {
public static void main(String[] args) {
double h =0.001;
int count =0;
do{
h*=2;
count++;
}while(h<=8848);
System.out.println(count);
}
}
这是三种方式 来计算这个 |