Untitled
unknown
plain_text
2 years ago
762 B
12
Indexable
import java.util.Scanner;
public class PatternPrinting {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the number of rows (M): ");
int m = scanner.nextInt();
System.out.print("Enter the number of columns (N): ");
int n = scanner.nextInt();
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
if (i == j || i == m - j - 1) {
System.out.print("#");
} else if (i % 2 == 0) {
System.out.print("#");
} else {
System.out.print("$");
}
}
System.out.println();
}
}
}
Editor is loading...