我试图在 Java 的帮助下画一个圆圈,但我被卡住了这是我到目前为止所做的,
public class Circle {
public static void DrawMeACircle(int posX, int posY, int radius) {
int a = 10;
int b = 10;
int x = posX - a; //x = position of x away from the center
int y = posY - b;
int xSquared = (x - a)*(x - a);
int ySquared = (y - b)*(y - b);
for (int i = 0;i <=20; i++) {
for (int j = 1;j <=20; j++) {
if (Math.abs(xSquared) + (ySquared) >= radius*radius && Math.abs(xSquared) + (ySquared) <= radius*radius) {
System.out.println("#");
} else {
System.out.println(" ");
}
}
}
}
public static void main(String[] args){
DrawMeACircle(5,5,5);
}
}
如您所见,这不能正常工作。有谁知道如何解决这个问题?迈克尔,我很感谢您提供的任何帮助。