java编写程序??假设一条绳子长3000米,每天减去一半的长度,请问需要花费几天的时间,绳子的长度短与5米?

来源:百度知道 编辑:UC知道 时间:2024/05/20 06:09:32

public class test {
public static void main(String[] args){
float SumRope = 3000.00f;
int sumDay = 0;
while(SumRope>5.0)
{
sumDay++;
SumRope/=2;
}
System.out.print("需要"+sumDay+"天");
}
}

int n=3000;
while(n<5){
n=n/2;
}