编程题4

用while循环找出n^2大于 12000的最小整数n,
用while循环找出n^3小于 12000的最大整数n

//用while循环找出n^2大于 12000的最小整数n
public class Demo4_13 {
	public static void main(String[] args){
		int n=0;
		while(Math.pow(n,2)<12000){
			n++;	
		}
		System.out.println(n);
		//用while循环找出n^3小于 12000的最大整数n
		int n1=0;
		while(Math.pow(n1,3)<12000){
			n1++;
		}
		System.out.println(n1-1);
	}
}

猜你喜欢

转载自blog.csdn.net/weixin_43283092/article/details/83007335