Untitled
unknown
plain_text
2 years ago
1.2 kB
5
Indexable
import java.util.Scanner; public class Main { private static void drawLineInUpperHalf(int i, int s) { int effectiveMaxLength = s / 2; for (int j = 0; j < effectiveMaxLength - i - 1; j++) { System.out.print(' '); } for (int j = 0; j < i + 1; j++) { System.out.print(j % 10); } System.out.println(); } private static void drawLineInLowerHalf(int i, int s) { int effectiveMaxLength = s / 2; for (int j = 0; j < effectiveMaxLength; j++) { System.out.print(' '); } for (int j = s - i - 1; j >= 0; j--) { System.out.print(j % 10); } System.out.println(); } private static void draw(int s) { for (int i = 0; i < s / 2; i++) { drawLineInUpperHalf(i, s); } for (int i = s / 2; i < s; i++) { drawLineInLowerHalf(i, s); } } public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("Введите s: "); int s = scanner.nextInt(); draw(s); } }
Editor is loading...
Leave a Comment