JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Inspired by a question:
// https://www.sololearn.com/Discuss/2937825/?ref=app
// How to draw a numerical matrix in zigzag pattern
// + Added a few customization options
// © 2021 SoloLearn Community
import java.util.Scanner;
public class Matrix
{
/*
Name
draw (static method)
Purpose:
draws contents of a <size> x <size> matrix in zigzag direction
Parameters:
<size> defines matrix size (rows & columns)
<ascending> : defines the range order:
(true) Matrix begins with 1 up to ( size x size )
(false) Matrix begins with ( size x size ) down to 1
<firstRowInReverse> : defines the order of values in first row (alternates inside the loop)
(true) First row is printed in reverse order
(false) First row is printed in normal order
*/
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run