1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
public class Circle
{ public static void main(String[] args) { int r = 6; for(int y=0;y<=2*r;y=y+2) { long x=Math.round(Math.sqrt(r*r-(r-y)*(r-y))); for(int i=0;i<=2*r;i++) { if(i==r-x||i==r+x) { System.out.print("*"); } else { System.out.print(" "); } } System.out.println(""); } }
}
|