/** * java控制台画椭圆 * */ public class Oval { public static void main(String[] args) { int r = 6; // 半径大小 int width = 6; // 水平长度 for (int i = -1 * r; i <= r; i++) { for (int j = 1; j < width * (r - Math.sqrt(r * r - i * i)); j++) { System.out.print(" "); } System.out.print("*"); for (int j = 1; j < width * 2 * Math.sqrt(r * r - i * i); j++) { System.out.print(" "); } System.out.println("*"); } } }