public class Difficult { protected static int[] buffer; protected static int width = 40; protected static int height = 40; private static void draw_line(int x, int y, int xx, int yy) { for(int sy = y; sy <= yy; sy++) { for(int sx = x; sx <= xx; sx++) { buffer[sy * height + sx] = 1; } } } public static void main(String [] args) { int speed = 1; int x = width / 2; int y = height / 2; buffer = new int[width*height]; for(int i = 0; i < height - 4; i++) { int dir = i % 4; switch(dir) { // up case 0: draw_line(x, y-speed, x, y); y -= speed; break; // left case 1: speed += 2; draw_line(x-speed, y, x, y); x -= speed; break; // down case 2: draw_line(x, y, x, y+speed); y += speed; break; // right case 3: speed += 2; draw_line(x, y, x+speed, y); x += speed; break; } } // draw for(int sy = 0; sy < height; sy++) { for(int sx = 0; sx < width; sx++) { if (buffer[sy*height+sx] == 1) System.out.print("█"); else System.out.print(" "); } System.out.print("\n"); } } }