n gibt die Anzahl der Kreise an die vertikal und horizontal gezeichnet werden. Unter dem Code befindet sich noch ein Hinweis zu den grünen Kreisen allerdings weiß ich nicht genau wie ich die durch die Schleife unterschiedlich erzeugten Kreise richtig platziere, so dass es für jedes n übernommen wird.
LG Reykja
Java:
public class Aufgabe5 {
public static void main(String[] args) {
int width = 300;
int height = 300;
StdDraw.setCanvasSize(width, height);
StdDraw.setScale(0, 300);
double n = 5;
double r = 300/n;
for (int a = 1; a <= n / 2; a++) {
StdDraw.setPenColor(StdDraw.GREEN);
StdDraw.setPenRadius(0.006);
StdDraw.circle(150, 150, r / 2);
StdDraw.circle((Math.sqrt(2* Math.pow(r, 2)) * a)/2+width/2 , (Math.sqrt(2 * Math.pow(r, 2)) * a)/2+width/2, r/2); //rechts oben
//StdDraw.circle((Math.sqrt(2* Math.pow(r, 2)) * a)/2, (Math.sqrt(2 * Math.pow(r, 2)) * a)/2, r/2);
//StdDraw.circle((Math.sqrt(2* Math.pow(r, 2)) * a) /2, (Math.sqrt(2 * Math.pow(r, 2)) * a) /2, r/2);
//StdDraw.circle((Math.sqrt(2* Math.pow(r, 2)) * a) /2, (Math.sqrt(2 * Math.pow(r, 2)) * a) /2, r/2);
}
}
}
LG Reykja